javascript - referencing multiple values inside an option element -
similar question can option in select tag carry multiple values? - except want reference values in javascript
to recap:
want return more 1 value selected item in selectbox - thinking this:
<select id='selectlist'> <option value1="a" value2="b" value3="c">option 1</option> <option value1="d" value2="e" value3="f">option 2</option> </select>
i want values of selected item:
var sel = document.getelementbyid('selectlist'); selvalue1 = sel.options(sel.selectedindex).value1; selvalue2 = sel.options(sel.selectedindex).value2; selvalue3 = sel.options(sel.selectedindex).value3;
currently can pull value='x' option need more values associated option. delimit 3 values 1 , later use string functions split them out, seem nasty.
i think looking attributes property:
var sel = document.getelementbyid('selectlist'); selvalue1 = sel.options[sel.selectedindex].attributes.value1.value;
Comments
Post a Comment