Dropdown selection without button [SOLVED]
Posted: Mon Feb 21, 2005 3:46 pm
Here's yet another item I've run into and am just stuck. I have a dropdown box thats built from PHP and I want to be able to git rid of the submit button and just be able to select an item from the dropdown and upon selection, have an action happen.
Here's my dropdown box:
I've been looking over the dropdown box tutorial here http://www.htmlcodetutorial.com/forms/_ ... hange.html but I couldn't put it all together.
I want to basically refresh the current page and pass the needed variables back to it:
items_to_show = <user selection via dropdown>
category = $category
mode = $_POST['mode']
This is what I had before I threw my hands up:
It would just take me back to the main site. For instance, if this page is at http://www.something.com/admin.php then selecting the dropdown would redirect me to http://www.something.com and not back to the admin.php page.
From what I read that uses javascript. Is there a way to do it in PHP?
Any ideas?
Paul
Here's my dropdown box:
Code: Select all
echo "<TABLE ALIGN=CENTER>\n";
echo "<TR>\n";
echo "<TD><P ALIGN=CENTER>Items to show per page</P></TD>\n";
echo "<TD><FORM NAME="items_per_page" ACTION="".$_SERVERї'PHP_SELF']."" METHOD=POST>\n";
echo "<SELECT NAME="items_to_show">\n";
$list = array(5, 10, 25, 50, 100);
foreach ($list as $inc)
{
echo "\t\t\t<OPTION VALUE="$inc"";
if ($inc == $_POSTї'items_to_show']) //Set user's preference as the one displayed
echo "SELECTED >$inc\n";
else
echo " >$inc\n";
}
echo "</SELECT></TD>\n";
echo "<INPUT TYPE=HIDDEN NAME="category" VALUE="$category">\n";
echo "<INPUT TYPE=HIDDEN NAME="mode" VALUE="".$_POSTї'mode']."">\n";
echo "<TD><INPUT TYPE=SUBMIT VALUE="Change"></TD>";
echo "</FORM></TR></TABLE>\n";I want to basically refresh the current page and pass the needed variables back to it:
items_to_show = <user selection via dropdown>
category = $category
mode = $_POST['mode']
This is what I had before I threw my hands up:
Code: Select all
echo "<TABLE ALIGN=CENTER>\n";
echo "<TR>\n";
echo "<TD><P ALIGN=CENTER>Items to show per page</P></TD>\n";
echo "<TD><FORM NAME="items_per_page" ACTION="".$_SERVERї'PHP_SELF']."" METHOD=POST>\n";
echo "<SELECT NAME="items_to_show" ONCHANGE="location = this.optionsїthis.selectedIndex].value;">\n";
$list = array(5, 10, 25, 50, 100);
foreach ($list as $inc)
{
echo "\t\t\t<OPTION VALUE="$inc"";
if ($inc == $_POSTї'items_to_show']) //Set user's preference as the one displayed
echo "SELECTED >$inc\n";
else
echo " >$inc\n";
}
echo "</SELECT></TD>\n";
echo "<INPUT TYPE=HIDDEN NAME="category" VALUE="$category">\n";
echo "<INPUT TYPE=HIDDEN NAME="mode" VALUE="".$_POSTї'mode']."">\n";
echo "</FORM></TR></TABLE>\n";From what I read that uses javascript. Is there a way to do it in PHP?
Any ideas?
Paul