Hi, so since two days I have a problem with my select field.
I have two values I want to use from this input, if it was possible, I would like to do this :
<SELECT NAME="flats">
<OPTION VALUE="74" value="1"> One
<OPTION VALUE="106" value="2"> Two
<OPTION VALUE="141" value="3"> Three
</SELECT>
i have tryed to do things like this :
<OPTION VALUE="4" id="four"> four
but when I try to get the value from $data = document.form.selectfield.id;
It does not work, the syntax seems to be incorrect.
I have tried to do an onclick to set the value on an hidden field like this :
<OPTION VALUE="42" onclick = "document.form.hidden5.value = 7;"> five
But onclick does not work on select fields :/
So, what is my goal ?
I have on my site a list (so a select field) of sizes of flat (1 room to 10 rooms), each line does have a value i need for some maths, but I need to save which choice the
user done (because some rooms have the same value)
I would be really grateful if someone can helps me :')
You can't have two attributes with the same name in a single element, even if one is upper case and the second is lower case. To browsers, these are identical and one will be ignored. I'd suggest that you find a different way to do whatever you're trying to do here.
You can use custom attribute names. These are valid in HTML5 and JavaScript will access them even if you use an HTML4 <!DOCTYPE>. Another approach would be to simply store the corresponding custom values in a JavaScript array and not embed them in your HTML at all. There are probably other ways to handle this, too, but its difficult to suggest anything without knowing more about what you're doing.
<SELECT id="flats">
<OPTION VALUE="74,1"> One </OPTION>
<OPTION VALUE="106,2"> Two </OPTION>
<OPTION VALUE="141,3"> Three </OPTION>
</SELECT>
then split like this
Bookmarks