X
xram
I am trying to populate a select list when it receives focus. I am
obtaining the data for the list via XmlHttpRequest and then using a
for loop to loop through each option and add it to the select using
the following code:
document.getElementById("selDesigner").options[0] = new Option("Select
a designer", "");
for (var i = 0; i < arrDesigners.length; i++)
{
document.getElementById("selDesigner").options[i + 1] = new
Option(arrDesigners.text, arrDesigners.value);
}
The select list is populated fine. The only problem I have occurs when
you click on the select list for the first time in IE6 or IE7, the
population of the select element causes it to close. It works fine in
Opera and Firefox however (i.e. the drop-down list stays open when
clicked).
I've also tried to add options to the drop-down list by setting the
innerHTML to a string containing the HTML of the option elements, but
this doesn't work either.
Has anyone found a workaround to this problem?
Any help much appreciated.
obtaining the data for the list via XmlHttpRequest and then using a
for loop to loop through each option and add it to the select using
the following code:
document.getElementById("selDesigner").options[0] = new Option("Select
a designer", "");
for (var i = 0; i < arrDesigners.length; i++)
{
document.getElementById("selDesigner").options[i + 1] = new
Option(arrDesigners.text, arrDesigners.value);
}
The select list is populated fine. The only problem I have occurs when
you click on the select list for the first time in IE6 or IE7, the
population of the select element causes it to close. It works fine in
Opera and Firefox however (i.e. the drop-down list stays open when
clicked).
I've also tried to add options to the drop-down list by setting the
innerHTML to a string containing the HTML of the option elements, but
this doesn't work either.
Has anyone found a workaround to this problem?
Any help much appreciated.