I have a form, with option tag. When it is submited. The selected option's value will be posted. What about I want to receive the value of id + title as well? How do I do it in php? <form> <select> <option id=1 value=2 title=3></option> <option id=2 value=3 title=4></option> </select> </form> PHP:
this is the way to get the value of the Dropdown box <?php if($_POST){ $cmbSelect=$_REQUEST['cmbSelect']; echo $cmbSelect; } ?> PHP: this is change in Html <form> <select name="cmbSelect"> <option id=1 value=2 title=3></option> <option id=2 value=3 title=4></option> </select> </form> HTML: hope it's helpful for you
Whenever you are wondering what a variable is in post, just have the page that is being posted to say print_r($_POST); That will output everything.
Why won't people try reading before trying to post a solution... all 3 above posts have shown him nothing new. These values are not submitted with the form, as they shouldn't (waste of bandwidth). You should have the corresponding data in a data store or at least hard coded in the script. But if you must, you can try JavaScript and assign the values to hidden inputs on submit but note that will be creating a JS dependency.