J
Joe Kelsey
The following works fine in Mozilla:
var makeSelect = function (firstOption, lastOption, thisOption,
thisList)
{
var select = document.createElement ("select");
for (var i = firstOption; i <= lastOption; ++i)
{
var option = document.createElement ("option");
option.value = i;
if (thisList)
{
option.appendChild (document.createTextNode (thisList));
}
else
{
option.appendChild (document.createTextNode (i));
}
if (i == thisOption)
{
option.selected = 1;
option.style.fontWeight = "bold";
}
select.add (option, null);
}
return select;
};
However, IE 6 complains about the select.add statement. The MSDN
documentation on select spouts some sort of blather about using
select.options.add, but that doesn't work either. I notice that IE
defines the add method to take an element and an index rather than two
elements, thus violating the DOM standard.
Any ideas?
var makeSelect = function (firstOption, lastOption, thisOption,
thisList)
{
var select = document.createElement ("select");
for (var i = firstOption; i <= lastOption; ++i)
{
var option = document.createElement ("option");
option.value = i;
if (thisList)
{
option.appendChild (document.createTextNode (thisList));
}
else
{
option.appendChild (document.createTextNode (i));
}
if (i == thisOption)
{
option.selected = 1;
option.style.fontWeight = "bold";
}
select.add (option, null);
}
return select;
};
However, IE 6 complains about the select.add statement. The MSDN
documentation on select spouts some sort of blather about using
select.options.add, but that doesn't work either. I notice that IE
defines the add method to take an element and an index rather than two
elements, thus violating the DOM standard.
Any ideas?