Forum Moderators: open
My requirement is to dynamically populate a drop down box (combo box) in a JSP Page, using a javascript function, with some values. This happens on click of some button.
I am using the below function to populate the drop down box. This runs fine in Windows IE, but in MAC, i get a javascript error saying " 'options' is not an object". Can anybody please tell me how to go about this? Is there any other way in which i could populate a drop down box? I need this to work in both Windows and MAC. Please help!
Function used:
// add an option item to the list
function fnAddListItem(obj)
{
optname = new Option("Sample","1",false,false);
obj.options[obj.length] = optname;
}
P.s: 'obj' here is my drop down box.
eval("document.forms[0].drpSampleBox");
Thanks in advance,
-Santhi.
fnAddListItem(document.forms[0].drpSampleBox);
I'm sure that Mac IE is somehow interpreting what you're trying to do as passing the eval function through as obj, which of course does not have an options property (though I have not tested this, it seems like it could be happening).
Even if you 'need' the eval currently, try what I've suggested, and if it works, then we can start weaning you off of using eval.