Reputation: 185
This is a really simple problem I can't figure out. I am trying to get the value of a dropdownlist using Javascript. I have 4 digit job codes in my dropdownlist. On a button click I got to this function and am trying to get the value of what was selected when a button was pushed.
function jobCodeToAdd() {
var jobCode = document.getElementById("<%=jobCode.ClientID%>"));
var selectedJobCode = jobCode.options[jobCode.selectedIndex].value;
What am I doing wrong? Thank you for your help.
Upvotes: 0
Views: 58
Reputation: 1492
I think what you are looking for is .text
var jobCode = document.getElementById("<%=jobCode.ClientID%>"));
var selectedJobCode = jobCode.options[jobCode.selectedIndex].text;
Upvotes: 1