2

I am trying to read the value of the selectedID in a drop down list in html through jQuery but it keeps producing an error. Did I miss something?

<select style="width: 80px;" class="text ui-widget-content ui-corner-all" id="metaList">
<option value="4d5e3a8c418416ea16000000">Wikipedia</option>  
<option value="4d5e3a8c418416ea16010000">Twitter</option>  
<option value="4d5e3a8c418416ea16020000">DBPedia</option>  
<option value="4d64cd534184162629000000">test</option>          
</select>        

I tried which used to work before

var temp = $("#metaList").val(); 

but it produces NULL!

2 Answers 2

2

Your function call is correct, but nothing is selected. That is the reason why NULL is returned.

Sign up to request clarification or add additional context in comments.

2 Comments

Oh! Guess what, Yes and No! I was selecting but I had two lists with the same id! So it was looking at the old one. Thanks for the idea!
First option of select list is always being selected by default
1

Try:

var temp = $("#metaList option:selected").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.