Drop Down (Option Tag)

Hi, my site has a drop down menu on it and i am using a JS script to display the chosen text from the drop down menu at the bottom of a page… my question is… the JS script reads the text in the value=“” below and not the text in between the <option> tags

<option value=“sample_text”>Sample Text</option>

Is it ok to display normal text (it is not 2 words instead of 1) in the value=“” for example <option value=“Sample Text”>Sample Text</option>

Thanks in advance for your help…

According to the W3C, the value attribute of OPTION elements is [url=http://www.w3.org/TR/html4/types.html#type-cdata]CDATA. It seems to me it should accept spaces so long as it’s in quotes. This isn’t true for all CDATA in HTML though so a validator check would be best.

You could also choose to use Javascript to grab the text inside instead of the value. This is referred to by options[particularOption].text.

Ok cool, thanks for your help…

I’ve had the same problem myself with options. They’re kinda picky.

Ok cool, what did you do in the end…

I think I used .text for the time where I wanted to do something with the [selectedIndex], and not .value. .value I used when I just needed to know which option was chosen in order to do something else unrelated to the text in the option.

Ok cool, thanks for your help…