
How to get the selected value from dropdown box? I am using javascript.

<html>
<head>
<title></title>
<script type="text/javascript">
function selectDropdown(){
var dropdownValue=document.getElementById("dropdown").value;
alert("You selected : " + dropdownValue);
}
</script>
</head>
<body>
Select any one:
<select id="dropdown" name="dropdown" onchange="selectDropdown()">
<option value="India" >India</option>
<option value="US" >US</option>
<option value="UK" >UK</option>
<option value="Japan" >Japan</option>
<option value="China" >China</option>
</select>
</body>
</html>
Description: Create dropdown list by using select and option tag. Now when you select any value from list, alert will display that. In var dropdownValue we are storing the selected value by using document.getElementById("dropdown").value .you can show this value in alert or any other way.

Hi... I need selected order too.... i mean, if i select 'US' at 1st & 'INDIA' 2nd means, i want select be 'US','INDIA'. not like 'INDIA','US'
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.