Question

How do I reset an ASP.NET dropdown, on the click of a link, using Javascript? No JS Frameworks.

Edit: reset, as in set the selected value to the first one in the list, as it would be when the page first loads.

Was it helpful?

Solution

Try this link

Do you want to remove all items of the dropdown or Select the first option(Default selected option)?

Try this :

document.getElementById("<%#mydropdownlist.ClientID%>").value = 0;

or

document.getElementById("<%#mydropdownlist.ClientID%>").selectedIndex = 0;

OTHER TIPS

You would probably want to get the control by ID then set the selectedIndex to 0.
for example:

var q = document.getElementById('dropdownId');
q.selectedIndex = 0;

Hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top