Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2004, 10:21 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default passing var from parent to child

Hey,

I'd like to know if this is possible, and how to do it if it is.

I'd like to be able to access the values of the parent window, and be able to use them in the popup.. I just can't seem to find out how to acces the variables of the parent in the popup...

Any help would be peachy...

 
Old April 12th, 2004, 10:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Take a look at the code about half way down this thread.
http://p2p.wrox.com/topic.asp?TOPIC_ID=11112



======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old April 12th, 2004, 10:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

This
document.all['aDIV1'].innerHTML = window.opener.window.form2.YOURCONTROLNAME.value;

assigns the content of the parent windows control to a <DIV>.
But to assign it to a variable or another control is just the same.

======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old April 13th, 2004, 11:45 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not sure I understand...

If I have a form

<form name="authen">
<input type="text" name="loginname">
<br>
<input type="text" name="password">
<br>
<input type="button" value="Submit" onclick="net_pop()">

...

How do I get the value of loginname, and password in the popup. I don't understand how to put the value in question in the div tag?

 
Old April 13th, 2004, 01:01 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Well, here's an easy way, but it might not work for you..

Add IDs to the form and its elements equal to the names. Then make your net_pop() function like this:

<script language=javascript>
function net_pop()
{
 var netPop = window.open("about:blank","netPop");
 netPop.document.write(document.forms.authen.loginn ame.value + "<br>" + document.forms.password.value);
}
</script>

This is just a simple example of passing the values. If you wanted to pass the values to a .asp or .php page in the popup, just make parameters in the location of the popup like this:

<script language=javascript>
function net_pop()
{
 var netPop = window.open("readform.php?username="+document.form s.authen.username.value+"&password="+document.form s.authen.password.value,"netPop");
}
</script>

Let me know if these solutions don't work.

Snib

P2P Member
<><
 
Old April 13th, 2004, 01:41 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

unfortunetly that won't work.. I actually have to assign those 2 values (loginname & password) to hidden fields... Cause, what I need to to be able to get to a tool that will show the results of the login, but I need it in a different window, hence the popup...

 
Old April 13th, 2004, 09:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

For your popups hidden fields set the value to the parent windows field values

<input type="hidden" name="HiddenLogin">


<script language="javascript">
HiddenLogin.value = window.opener.window.authen.loginname.value;
</script>

======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
parent child connect s2mo SQL Server 2005 1 February 20th, 2007 07:16 AM
parent child form data passing maddy137 ASP.NET 1.0 and 1.1 Basics 0 April 26th, 2006 01:00 PM
passing js var to asp sql okl Javascript 1 March 11th, 2005 05:40 AM
passing js var to asp sql okl Classic ASP Databases 1 March 11th, 2005 05:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.