Problem with dropdown list
Hi,
I wonder if anyone can help me?
I added an option to my dropdown list and set it as the default option using the Options Constructor as depicted below. The problem is that when the page reloads the default option is always the selected one even when the user has selected a different item. Please how can I make the dropdown forget the default option and select what the user has selected? Any help will be much appreciated.
<body onload="updateDropList()">
<form name="form1">
<select name="colour" onchange=updateDropList()>
'populate this dropdown with values from database
</select>
</form>
</body>
function updateDropList()
{
var select = document.form1.size;
var code = select.options[select.selectedIndex].value
//add the 'all' option and make it the default
var default_option = new Option ("all","-1",true,true);
for (i=0; i < products[code].length; i++)
{
// populate a second dropdown with values from the database
}
// Display the new option in the store_stock Select element
document.form1.options[products[code].length] = default_option;
}
|