0

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?

1
  • you are missing (). Use like `var split = this._ddlName.value().split('-')[0];' Commented Jan 6, 2015 at 9:40

2 Answers 2

1

You are missing ()

To get value

$('#dropDownId').val();

To get the currently selected text:

$('#dropDownId :selected').text();
Sign up to request clarification or add additional context in comments.

Comments

1

Since you are using JQuery:

To get the selected value

$("#id").val();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.