I want to carry some extra hidden information (eg: postal code) in an HTML select/option dropdown list and make it available to a javascript function when user changes option box selection.
This is the type of thing I would like to do (but it does 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, you can define your own attributes just prefix them with data-. Like data-info, data-zip or whatever.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With