Yuval200 Posted October 9, 2006 Share Posted October 9, 2006 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 More sharing options...
boen_robot Posted October 9, 2006 Share Posted October 9, 2006 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 More sharing options...
justsomeguy Posted October 9, 2006 Share Posted October 9, 2006 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 More sharing options...
Yuval200 Posted October 10, 2006 Author Share Posted October 10, 2006 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 More sharing options...
justsomeguy Posted October 11, 2006 Share Posted October 11, 2006 Options don't need a name, they are all options for the named select list. You can give the options an id if you want to access them through javascript, but otherwise you don't need one. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now