...

View Full Version : Javascript : Opening handeling textbox in popup window



Terrorke
10-28-2004, 11:59 AM
Hi there

I want to controle the value of a text field in a popup window.

the window is opened by the code:

win = window.open(url.asp)

This new window contains a form with an textbox in it.

Now how can I access this textfield in the code of the parent window??

Thanx in advance

Grtz
Terrorke

fci
10-28-2004, 12:06 PM
win.document.form_name.element_name.value ...

jbot
10-28-2004, 12:07 PM
I want to controle the value of a text field in a popup window.

this new window contains a form with an textbox in it.

Now how can I access this textfield in the code of the parent window??

you've confused me: which window do you wanna control - the popup (child) or opener (parent)?

fci
10-28-2004, 12:11 PM
you've confused me: which window do you wanna control - the popup (child) or opener (parent)?

oh.. mm I 'm too tired, I probably misintrepted then.. *head explodes*

if you're going from the popup to the parent window
opener.document.form_name.element_name.value ..

Terrorke
10-28-2004, 01:01 PM
I whant to controle the child via the parent.

So let' say :

in the child window (the popup) there is a text field called Username.

How can I set its value in the parent after I open the new window?

Grtz

Terrorke

fci
10-28-2004, 01:07 PM
I whant to controle the child via the parent.

So let' say :

in the child window (the popup) there is a text field called Username.

How can I set its value in the parent after I open the new window?

Grtz

Terrorke


window.opener.document.form_name.element_name.value

Terrorke
10-28-2004, 01:12 PM
window.opener.document.form_name.element_name.value

I have tried to do that but than I always get an error like

"Win.document.form1.username is not an object"

Maybe I wasn't so clear. I want to control an element in the child form the parent. And not the way around.

Grtz
Terrorke

jbot
10-28-2004, 02:12 PM
I have tried to do that but than I always get an error like

"Win.document.form1.username is not an object"

Maybe I wasn't so clear. I want to control an element in the child form the parent. And not the way around.


well, then this should work so long as it's in the opener:

<a href="#" onclick="if (win && !win.closed) win.document.form1.username.value='whatever'"; return false">change value</a>

JS is case sensitive!!

Terrorke
10-29-2004, 08:07 AM
It didn't work yet, but I will carry on my quest.

If I find a solution, I will post it here.

Thanx anywayz for your time and suggestions.

Grtz
Terrorke

Roy Sinclair
10-29-2004, 05:36 PM
You say that the popup window is opened with this code:

win = window.open(url.asp)

Understand then that the variable "win" returned from the window.open function is an object reference to the "window' object of the newly opened popup window. However, the snippet of code you gave above doesn't tell the whole story because of this commonly performed mistake:




function ABadWayToOpenAPopup(newURL)
{
var win;
win = window.open(newURL);
}



If the variable "win" is declared within the function then there's no way you can reference the returned object outside of that function. The "win" variable should be a global object or attached as a property of a global object so that it can be used later. If your "win" object isn't declared global then it's possible that's why you can't get the suggestions provided here to work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum