|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
jump menu question
More of a HTML question than PHP but it deals with PHP so I thought I would post it here.
I have a script that displays the contents of of a table. I want a drop down "jump menu" with (in this example) 3 options. When choosing the option it basiclly calls the same page where my php script is located which take the value of the select form and uses it in a switch statement to determine which kind of query to display. The options are how the table will look. A self designed 'web' style, alphabetical by last name and by first name. Code:
<?
echo "The value of display is: ".$display."<br>";
?>
<form name="form1">
<select name="display" onChange="MM_jumpMenu('parent',this,0)">
<option value="web" selected>Website Style</option>
<option value="alphaL">Alpabetical(last name)</option>
<option value="alphaF">Alpabetical(first name)</option>
</select>
What happens when I use this jump menu it uses the value in the options to use a the page to jump too. I can get it to work by using a submit button, but I'm wondering how to do it just by the choice that a person chooses. Thanks, Fozzy |
|
#2
|
|||
|
|||
|
Select Elements have an 'onchange' event.
You can handle that event by submiting your form when something changes. This is untested, but it would look something like this: <select onchange="this.submit();"> ... ... </select> this.submit may or may not work; you may have to reference your form manually such as: document.all.formname.submit();
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
Hmmm... I tried that but it doesn't seem to be working.
It seems jump menu doesn't change anything to PHP variables or something because I get an error... Warning: Undefined variable: jump in C:\Program Files\Apache Group\Apache\root/jumpmenu.php on line 18 for this... Code:
<?
echo "The value of jump is: ".$jump."<br>";
?>
and I don't get it when I implement the method and action section of a form with the submit button. I'm just wondering how to just remove that pesky submit button and just have it work off of 'onChange'. Here's my full code. Code:
<?
echo "The value of jump is: ".$jump."<br>";
?>
<form name="form1" >
<select name="jump" onChange="document.all.form1.submit()">
<option value="web" selected>Website Style</option>
<option value="alphaL">Alpabetical(last name)</option>
<option value="alphaF">Alpabetical(first name)</option>
</select><br>
</form>
<?
echo "The value of normal is: ".$normal."<br>";
?>
<form name="form2" method="post" action="jumpmenu.php">
<select name="normal" onchange"">
<option value="web" selected>Website Style</option>
<option value="alphaL">Alpabetical(last name)</option>
<option value="alphaF">Alpabetical(first name)</option>
</select>
<input type="submit" name="Submit" value="Submit">
</form>
Cheers, Fozzy |
|
#4
|
|||
|
|||
|
Working Sample:
Code:
<form name="form1" id="form1" action="http://www.laidbak.net/" method="get">
<select name="menu1" onchange="document.all.form1.submit();">
<option selected="selected">Test1</option>
<option>Test2</option>
</select>
</form>
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > jump menu question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|