PDA

View Full Version : Help changing a form in a new window


golfboy
04-16-2003, 04:02 PM
I have written a function that opens a new window and then fills in a couple of form fields in that new window. The code works fine when I test it on my computer, however when the pages are uploaded to the internet the code no longer works. I get an error that the form I am referring to does not exist. I believe the problem to have something to do with the new window not being completely loaded. If I add any kind of alert() in the code after the window is opened but before the form fields are to be filled in, the code works fine. Is there anyway to pause the code until the new window is completely loaded? Or a way to tell when the new window is completely loaded? Or am I totally off in what I think is wrong?

Any help would be much appreciated. Here is the function:
function fillInTheForm(bagname, price, the_url) {

var height = window.screen.availHeight;
var width = window.screen.availWidth;

var left_point = parseInt(width/10);
var top_point = parseInt(height/30);

var new_window=window.open(the_url, "new_window", "width=680,height=400,scrollbars,toolbar,menubar,resizable");

new_window.focus();
new_window.moveTo(left_point,top_point);

new_window.document.forms[0].bag_desc.value = bagname;
new_window.document.forms[0].price.value = price;
}

Spudhead
04-16-2003, 04:16 PM
I'm really stabbing in the dark here, and bear in mind it was a long, beer-fuelled lunch hour, but:

I'm not sure about the variable "new_window" being used to reference a window of the same name. Try changing one, see if that helps.

You could also try referencing the form by name directly, rather than forms[0].

Sorry if that wasn't any help :):rolleyes:

golfboy
04-16-2003, 05:24 PM
Spudhead,

Wow, a beer-filled lunch hour sounds good, but a bit early for that here. I tried your suggestions to no avail. Thanks anyway.

PauletteB
04-16-2003, 06:25 PM
,"width="

No second quote

,"width=680

golfboy
04-16-2003, 06:59 PM
Paulette,

Thanks for finding that error, but that was just a typo when I posted my message. I have it correct on the site and I updated my earlier post.