Re: Call another page after the menu had been selected
| From: | Mike Flynn | Date: | Fri, 28 Dec 2001 15:01:31 +0000 |
| Subject: | Re: Call another page after the menu had been selected | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-11175@lists.php.net to get a copy of this message | ||
At 02:10 PM 12/28/2001 +0800, you wrote:
Dear all I'm using UltraDev which build a form containing a menu, there a two items inside this menu for user to choose. This form is using Post Action to $php_self which means it will pass back the variable to itself. Then here is the question: what should i do if i want to call a page prompt from a blank window when the item A is selected? and another page when Item B is selected! thx a lot jack jack@nedcor.comI'm not sure what you mean by "call a page prompt from a blank window when item A is selected". Do you mean at the exact moment that item A is selected, or do you mean after the user has submitted the form? If you mean you want to pop a new window as soon as the user selects one of the pulldown options, then you use JavaScript for that. Something like this: <script language="JavaScript"><!--//
function loadpage(thepage) {
if (thepage) {
self.location = thepage;
}
}
//--></script>
<form action="./" method="post" name="theform">
<select name="pages" onChange="loadpage(this.options[this.selectedIndex].value);">
<option value="0">--- Please select one: ---</option>
<option value="page1.php">Page 1</option>
<option value="page2.php">Page 2</option>
<option value="page3.php">Page 3</option>
</select>
</form>
If you mean you'd like it to redirect them after they submit the form, you could do it with the PHP..
[before any other HTML code]
<?php
if ($submitted && $pages) {
// .. do stuff..
header("Location: $pages\r\n\n");
exit();
}
?>
[...html code...]
<form action="./" method="post" name="theform">
<select name="pages">
<option value="0">--- Please select one: ---</option>
<option value="page1.php">Page 1</option>
<option value="page2.php">Page 2</option>
<option value="page3.php">Page 3</option>
</select><br>
<input type="hidden" name="submitted" value="1">
<input type="submit" value="Go to page">
</form>
...
Hope that helps.
-Mike