Click to See Complete Forum and Search --> : Adding new information to a select


trperry
12-19-2002, 02:22 PM
I have a web page that has got various admin fields in it. One of these fields is a select box. next to the select box i have an icon that will open a new window to allow the user to enter new information.

what i want to be able to do is for the relevant information from window2 to be added to the select box in window1.

this is the code that i have got in window2 at the moment. this is goign to be activated when the page is submitted and will eventually get its values from what was on the form

var objWindow = window.opener;
numElements = objWindow.document.getElementById('DriverID').length;

DriverName = "a new driver";
DriverID = 26;

objWindow.document.forms[0].DriverID.options[objWindow.document.forms[0].DriverID.length] = new Option(DriverName, DriverID, true, true);

when i execute this i either get "the server returned an exception" or the browser crashes!

Can anyone see what is wrong with this code or suggest a different way of doing this?

trperry
12-20-2002, 03:44 PM
hey dave,

cheers for you help, that works a treat. I have a nice bump on my head from banging it on the desk !

As i might want to use this functon in other areas of the site, I have put it into a external js file and then included it on the page. when i run the script now i get an "Object expected" error, but the code executes and inserts the data into the select box.

any ideas?

using IE 6 SP1, on win2k pro