Basically I have an option box and I want it to display the value when I click on it. The tricky part is that I want each option to store two values. Something like this:
<select name="Choices" onChange="displayStuff()"> <option value="apple" myType="fruit" >Apple <option value="orange" myType="fruit" >Orange <option value="carrot" myType="veggie" >Carrot </select>
in my JavaScript, I try to extract the 'myType' value by this:
function displayStuff() { box = document.formname.Choices; curType = box.options[box.selectedIndex].myType; alert(curType); }
The above code works in IE, but not with Mozilla Firefox.
In Firefox this line: box.options[box.selectedIndex].myType gives me "undefined".
I think it might be because I was a little bit cheating when I added the "myType" tag since it's not a standard tag. Do you know how I can get around the issue? (custom taglib is not an option) Is there a way to store 2 values in 1 selection in the option box? Or can I store the extra information in some kind of hidden fields?
Thanks in advance!