Click to See Complete Forum and Search --> : Drop down list text (not value) with PHP


Hazel2003
06-14-2006, 08:47 PM
I have a php email form where the subject is a drop down list and the text is tied to an email value. For example depending on what subject you pick will determine who the form gets mailed to. However, when the email is sent I want the text to show up in the subject of the email and not the value of the drop down list. I would get that value with javascript this way...

var w = document.emailForm.requiredSubject.selectedIndex;
var selected_text = document.emailForm.requiredSubject.options[w].text;
return selected_text;

How do I do this with PHP? Mind you I know "just enough" PHP to get me by. Thank you for your help.

NogDog
06-15-2006, 12:12 AM
All PHP will receive in the $_POST array for the select element is the value of the selected option. If that is not what you want to output, then you'll need to build a data structure of option values and associated texts. You could do this with a database, or just by defining an array where the keys are the values of your select options and the array values are the texts you want associated with those values.

Hazel2003
07-02-2006, 06:19 PM
I have been looking at this - again I am just learning PHP. I don't think the array will work. The value of the dropdown box is the email address that I am using to send the form. The text are subjects that the user wants information on. There are duplicate email values as mulitple subjects may be mailed to the same person.