Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to set an item to default in dropdown list
Posted

JavaScript
$("#myDropdown").val("0");
// specify your default item value


-KR
 
Share this answer
 
A simple google search:
http://lmgtfy.com/?q=javascript+how+to+set+an+item+to+default+in+selected+option[^]

Found this:
Here is a Javascript version (also jQuery).
http://stackoverflow.com/questions/19611557/how-to-set-default-value-for-html-select[^]

Quote:

JavaScript
var temp = "a";
var mySelect = document.getElementById('mySelect');

for(var i, j = 0; i = mySelect.options[j]; j++) {
    if(i.value == temp) {
        mySelect.selectedIndex = j;
        break;
    }
}


Hope it helps out.
 
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