Http://www.cnblogs.com/tonyqus/archive/2005/05/18/158357.html
If we want to dynamically add an option using JavaScript in a common form, we will write: document. form1.list1. options [0] = New Option ("A1", "A1 ");
Suppose there is a form named form1, and one list1 is the list.
If the above Code is called in the current window, a text = "A1", value = "A1" will be added, equivalent to the Code <option value = "A1"> A1 </option>
Note: The opener mentioned in this Article refers to a window for opening another window, and another window is called an opened window in this article.
Since this method is feasible, can we control the opener form in the opened form and create an option in the opener form? The theoretical code is as follows: zookeeper opener.doc ument. All. list1.options [0] = New Option ("AA", "AA ");
Assume that the opener form contains a list with name = list1.
However, if the above code is executed, it will not produce any effect. If we analyze the cause, we will find that the object generated by new option () is in the opened form, rather than in the opener form, which is specified in javascript: only allow the form to access its own variable object. Therefore, the correct method should be: var newopt?##opener.doc ument. createelement ("option ");
Newopt. Text = "AA ";
Newopt. value = "AA ";
Zookeeper opener.doc ument. All. list1.options. Add (newopt );
In this way, you can create an option in the opener form.