CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   Resolved Parent/Child form interaction (http://www.codingforums.com/showthread.php?t=274183)

WolfShade 09-25-2012 06:12 PM

Parent/Child form interaction
 
Someone recently posted a question about having a child form that could update values in a parent form. So I started toying around with the idea.

I have a form that includes a link that will open a popup with an identical form; any changes done to the child form are reflected in the parent form.

I'm trying to do vice-versa, and am hitting a wall.

I'm setting a variable to a function that spawns the popup, but that variable is "undefined" when I try to access it.

var childForm = messageWindow(args); (messageWindow is the function and it's too much code to type, here.)

So.. how does one reference a child window in JS?

Thanks,

WolfShade 09-26-2012 07:35 PM

CAN one reference a child window in JS?

AndrewGSW 09-26-2012 07:57 PM

Code:

var childForm = messageWindow(args);
Your messageWindow function needs to return a reference to the child window:

Code:

function messageWindow(args) {
    var theChild = window.open(...);
    return theChild;
}

From the parent you can reference elements in the child with:

Code:

theChild.document.etc
(I haven't tested this recently..)

WolfShade 09-26-2012 08:29 PM

Ah, HA! Within the function, I am assigning a different variable to the window.open, but I am not returning it. Thanks, Andrew! I'll give that a shot and report back.

WolfShade 09-26-2012 08:45 PM

High-five, Andrew. I don't know why it didn't occur to me to actually return the object. That nailed it.

Thank you,


All times are GMT +1. The time now is 08:27 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.