Jump to content

PHP and the <select>/<option> tags?


Yuval200
 Share

Recommended Posts

Hey guys :)I'll try to make it short as possible.I have like 4 select tags, with some options tags (Each option has a value attribute) on each select tag. When the user sends the form, how do I know witch option tag he selected? Oh yes, and if I have a select tag, how do I know what option tag was selected?Thanks in advance,Yuval :)

Link to comment
Share on other sites

Well, you can check the $_POST or $_GET value of the form element. And to select the proper element, you need to give it a name. For details, look into the W3Schools' PHP tutorial.

Link to comment
Share on other sites

To expand on that, check the value of the variable with the name of the select tag. So, if you have a select tag like this with a name:<select name="some_name">And if your form gets submitted through POST, then this variable will contain the value of the selected option:$_POST['some_name'];

Link to comment
Share on other sites

Hehe guys, I'm not that newbie, I know how to post data that is sent by the browser with inputs and textareas.I was reading the page about the option tag, and it used the "value" attribute, and not the name/id attributes.So ok, I can reach the select by giving it a name. that's good. I tried it now, and by giving the select tag a name and id, it outposted the selected option.Thanks guys, I'll post again if I'll have more problems :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...