Reputation: 143
I keep getting an error on this saying its undefined or its null. How do I get the drop down lists value?
So far I have:
this._ddlName = $("[id$=ddlName]"), elm);
var split = this._ddlName.value.split('-')[0];
The top line of code is working since I'm using it elsewhere to do something else. But the bottom one throws the error. Any suggestions?
Upvotes: 0
Views: 136
Reputation: 33809
Since you are using JQuery:
To get the selected value
$("#id").val();
Upvotes: 1
Reputation: 1068
You are missing ()
To get value
$('#dropDownId').val();
To get the currently selected text:
$('#dropDownId :selected').text();
Upvotes: 1