Reset all select dropdowns
With raw javascript code, we can do the following,
elements = document.getElementsByTagName("select")
for(i=0; i < elements.length ; i++){
elements[i].selectedIndex= 0;
}
function displaymessage() {
$("select").each(function() { this.selectedIndex = 0 });
}
this selects the first option (not necessarily having value = 0)
How about something like:
$(window).unload(function () {
$("select").val("0");
});
Here´s a way to select the first option in all select
s using native JavaScript;
var elements = document.getElementsByTagName('select');
for (var i = 0; i < elements.length; i++)
{
elements[i].selectedIndex = 0;
}
...but jQuery is very handy and makes most things much easier.