Jump to content

Forms and PHP: Getting Option Value into PHP


FangerZero

Recommended Posts

OK how do I get the VALUE, not the text, into PHP as a variable after pushing a button?

 

What I'm doing is, I have two Pages. a Main Menu page; where you can select which option you want. Then a viewing page; to view anything attached to the data that was selected. You go from Main Menu to viewing page via button. 

 

And I know to get the selected text so if I chose Dogs, I would know how to get that printed out on View, but I need the '1' from Value.

 

<form name="MainMenu" method="POST" action=View.php>
<input type="submit" name="View" value="View">
<select name=Animal size=5>
<option value=1>Dogs</option>
<option value=2>Cats</option>
<option value=3>Fish</option>
<option value=4>Birds</option>
</select></form>

You're asking for the value, he gave you the way to get the value. You're asking the question wrong, so expect a wrong answer. Simply put, you can't do what you want. Why don't you just make the value "Dogs" if that's what you want?

Also you shouldn't rely on just names as identifiers in input and select objects.  use name="" and id="" at the same time, and make sure they're both the same.  Also, why is your select size=5 if there's only 4 options?  And finally, use quotes.  Different browsers handle code differently, using proper code standards helps eliminate cross-browser issues.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.