Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Pass dataset from select option to javascript function

Avatar of MortenWB
MortenWBFlag for Denmark asked on
JavaScriptASPHTML
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;
}

</script>

<body>

<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="this.style.cursor='pointer';" >
<%=EqCatList("EqCatDesignation")%>
</option>

<%
EqCatList.movenext
loop
%>
</select>

<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 />

</body>
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971Flag of Guadeloupe imageMultitechnician
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers