Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-28-2004, 10:59 AM   PM User | #1
Terrorke
New to the CF scene

 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Terrorke is an unknown quantity at this point
Javascript : Opening handeling textbox in popup window

Hi there

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

the window is opened by the code:
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
Terrorke is offline   Reply With Quote
Old 10-28-2004, 11:06 AM   PM User | #2
fci
Senior Coder

 
Join Date: Aug 2004
Location: Twin Cities
Posts: 1,345
Thanks: 0
Thanked 0 Times in 0 Posts
fci is an unknown quantity at this point
win.document.form_name.element_name.value ...
fci is offline   Reply With Quote
Old 10-28-2004, 11:07 AM   PM User | #3
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
Quote:
Originally Posted by Terrorke
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)?
__________________
*keep it simple (TM)
jbot is offline   Reply With Quote
Old 10-28-2004, 11:11 AM   PM User | #4
fci
Senior Coder

 
Join Date: Aug 2004
Location: Twin Cities
Posts: 1,345
Thanks: 0
Thanked 0 Times in 0 Posts
fci is an unknown quantity at this point
Quote:
Originally Posted by jbot
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 ..
fci is offline   Reply With Quote
Old 10-28-2004, 12:01 PM   PM User | #5
Terrorke
New to the CF scene

 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Terrorke is an unknown quantity at this point
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
Terrorke is offline   Reply With Quote
Old 10-28-2004, 12:07 PM   PM User | #6
fci
Senior Coder

 
Join Date: Aug 2004
Location: Twin Cities
Posts: 1,345
Thanks: 0
Thanked 0 Times in 0 Posts
fci is an unknown quantity at this point
Quote:
Originally Posted by Terrorke
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
Code:
window.opener.document.form_name.element_name.value
fci is offline   Reply With Quote
Old 10-28-2004, 12:12 PM   PM User | #7
Terrorke
New to the CF scene

 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Terrorke is an unknown quantity at this point
Quote:
Originally Posted by fci
Code:
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
Terrorke is offline   Reply With Quote
Old 10-28-2004, 01:12 PM   PM User | #8
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
Quote:
Originally Posted by Terrorke
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!!
__________________
*keep it simple (TM)
jbot is offline   Reply With Quote
Old 10-29-2004, 07:07 AM   PM User | #9
Terrorke
New to the CF scene

 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Terrorke is an unknown quantity at this point
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
Terrorke is offline   Reply With Quote
Old 10-29-2004, 04:36 PM   PM User | #10
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
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:

Code:
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.
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:58 PM.


Advertisement
Log in to turn off these ads.