Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all, i have a quick question. I have a webpage that has an asp:Dropdownlist control. How can i get the SelectedValue of this dropdownlist in my javascript?

e.g: var value = document.GetElementById(DDL).Value
Posted

XML
var ddl = document.getElementById("<%=DDL.ClientID%>");
var SelVal = ddl.options[ddl.selectedIndex].text;
alert(SelVal); //SelVal is the selected Value

Reference
1. get selectedvalue of dropdownlist using javascript in asp.net[^]
2. Get selected value of asp:dropdownlist in javascript:[^]
 
Share this answer
 
I got the solution here...
 
Share this answer
 
Try below code:
JavaScript
var e = document.getElementById("ddlLocation");  
var selectedLocation = e.options[e.selectedIndex].value; 
 
Share this answer
 

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