PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
vigour
Forum Newbie
Posts: 18 Joined: Thu Sep 29, 2005 2:04 am
Post
by vigour » Fri Oct 07, 2005 2:21 am
I want this code to call process.php when I select something in the drop down list. How can I do this?
Code: Select all
echo '<html>';
echo '<body>';
echo '<form action="process.php" method="post">';
echo '<select name="item">';
echo '<option>1</option>';
echo '<option>2</option>';
echo '<option>3</option>';
echo '</select>';
echo '</form>';
echo '</body>';
echo '</html>';
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Fri Oct 07, 2005 3:26 am
Code: Select all
echo '<select name="item" onchange="this.form.submit()">';
you are better off outputting static HTML outside PHP instead of using PHP to output HTML.
vigour
Forum Newbie
Posts: 18 Joined: Thu Sep 29, 2005 2:04 am
Post
by vigour » Fri Oct 07, 2005 3:35 am
Thanks, that worked. Is there a way to set a drop down list to a value with PHP? For example, I have 3 values in the drop down list, 1 2 3, and I want to set it to any of these values with PHP.
n00b Saibot wrote: Code: Select all
echo '<select name="item" onchange="this.form.submit()">';
you are better off outputting static HTML outside PHP instead of using PHP to output HTML.
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Fri Oct 07, 2005 3:46 am
Lets says $item stores the selection. then
Code: Select all
echo "<option ".($item==1?' selected':'').">1</option>";
likewise others.