keith1001
asked on
PHP / Form get value and selection from Select Box.
I have an HTML form with a select box. I cant figure out how to pass along the option value (index value) and also the selected name of a <SELECT> box. I need to be able to access both via the $_POST[]. I can get the option vale but not the text of the selected option.
That's the way it works. If you want the text, you have to include it in the value.
So you gonna to have a hidden field for example, and use javascript to set its value with the option's selected Text value. By saving value into a hidden field, you should able to retrieve it after your form was posted.
This is by design because your PHP should be able to work out the text from the value of the option. Given how easy it is to spoof data, you should do some server side validation regardless.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This what I was looking for, excellent. Thanks for a nice clean example and other useful links!