Click here to Skip to main content
14,970,162 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Every one,

Could any one please tell me how to get the dropdown list values in javascript..


Hope this code will guide you.

var e = document.getElementById("dropdown1"); // select element
var strUser = e.options[e.selectedIndex].value;
Raj.rcr 21-May-11 0:34am
Thanx a lot... Perfect answer.. My 5
[no name] 21-May-11 5:57am
You're welcome Raj..

Please always provide your code to get the accurate solution, I assume your dropdown id is select1 and by using JQuery you can retrive the options. Use this code below
var domelts = $('#select1 option');
var values = $.map(domelts, function(elt, i) { return $(elt).val();});

first get the elements into a list and next translate that into an array of just the values. Later you can iterate the array items to get values.

Hope this will help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900