As with many others at the site, this script came about as a result of helping someone at one the forums I frequent, The problem was how to append options from a child window to a selection list in the parent window. After pointing out the solution, I decided to play with the script and add a little more functionality. The following tutorial is the result.

Unlike many of the scripts here, this page contains only one function -- OpenWin() -- all of the other code (for selecting the data and creating the selection list options) is located in the child window.

In fact, the only interesting thing about the function is the url itself. As you can see from the HTML code below, I appended the formname and selection list name to the document's file name. This was done so that, if wanted, the function could be used with more than one selection list

Since the form and selection list names are encoded in the url's location string, the first thing the child window does is parse the location with the location.search property. Note that substr(1) returns only that part of the string after the question mark. The resultant string (in this case: 'mainpage.list1') is then prefixed with the appropriate DOM and eval()ed to create an object with which we can later manipulate.

The rest of the child window consists of a form with elements and data, and two functions: addSelected() and selectAll(). The former function is activated when the user hits the 'Add Selected Names' button.

The function itself loops through the child window's form's checkboxes. Once it locates a checked one, it creates a new option for the parent's selection list. Note that I am substr()ing the checkbox's value so that the email address is assigned to the option's value and only the name appears as the option's text.