javascript - carry some extra information in an HTML select/option dropdown list -
i want carry hidden information (eg: postal code) in html select/option dropdown list , make available javascript function when user changes option box selection.
this type of thing (but not work).
<select id="sel_activity" onchange="selectionchange(this.info)"> <option info="" value="car">car problem</option> <option info="" value="coffee">coffee break</option> <option info="45678" value="inv">inventory count</option> <option info="23567" value="invdrop">inventory</option> <option info="" value="lunch">lunch break</option> <option info="87654" value="meet">meeting</option> </select> . . . function selectionchange(info){ alert(info); }
html 5 provides data-* attributes, can define own attributes prefix them data-. data-info, data-zip or whatever.
Comments
Post a Comment