[Javascript] Adding a new <option> in Netscape

Andrew Dunn adunn at mail.interworx.com.au
Thu May 3 08:19:31 CDT 2001


Hi,
   I'm a newbie when it comes to javascripting. I have a script which adds a
new <option> tag to a <select> list box. The core of my script is as
follows:


for (var i=0; i < eval(nameID + ".length + 1");i++)
			{
				eval("document.location." + changeObj + ".options[" + i + "] = new
Option");
				eval("document.location." + changeObj + ".options[" + i + "].value =" +
nameID + "[" + i + "]");
				eval("document.location." + changeObj + ".options[" + i + "].text =" +
nameName + "[" + i + "]");
			}



This is only part of the script but it is the part that adds the <option>
tag. The script works fine in Internet Explorer but when I try it in
Netscape 4.08 it does not work (I only want to support these two browsers).
I know it is possible to add <option> tags in Netscape 4 browsers because
I've seen it done on other sites.

Does anyone know how this is done?

Thank you for your anticipated help.

Andrew.






More information about the Javascript mailing list