troubleshooting Question

Pass dataset from select option to javascript function

Avatar of MortenWB
MortenWBFlag for Denmark asked on
6 Comments1 Solution1232 ViewsLast Modified:
Hi Experts,

I attempt to send a dataset from an asp loop populated <OPTION> list to a javascript function using an onChange event in the <SELECT> tag, but get only "undefined" as output. What do I miss? heres my code:

<script type="text/javascript">

function UpdatecatPopup(){

var d = document.getElementById('EqCatList');
var _EqcID = d.options[d.selectedIndex].dataset['EqcID'];
var _des = d.options[d.selectedIndex].dataset['des'];
var _bet = d.options[d.selectedIndex].dataset['bet'];
var _descr = d.options[d.selectedIndex].dataset['descr'];
	document.getElementById('EditEqcID').innerHTML = _EqcID;
	document.getElementById('EditDesignation').value = _des;
	document.getElementById('EditBetegnelse').value = _bet;
	document.getElementById('EditDescription').value = _descr;



<select id="EqCatList" name="EqCatList" onChange="UpdatecatPopup();" >
do while not EqCatList.EOF
<option data-EqcID="<%=EqCatList("EqCatID")%>" data-EqCatDesignation="'<%=EqCatList("EqCatDesignation")%>'" data-EqCatBetegnelse="'<%=EqCatList("EqCatBetegnelse")%>'" data-EqCatDescription="'<%=EqCatList("EqCatDescription")%>'" onMouseOver="'pointer';" >


<div id="EditEqcID" name="EditEqcID" class="EqCatinput" ></div><br />
<input type="text" id="EditDesignation" name="EditDesignation" class="EqCatinput" ><br />
<input type="text" id="EditBetegnelse" name="EditBetegnelse" class="EqCatinput" ><br />
<input type="text" id="EditDescription" name="EditDescription" class="EqCatinput" ><br />

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros