473,473 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Passing values between different windows

11 New Member
Hello JS newsgroup

The main window of my Website opens a child window as you can see
below:

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript"> 
  2.     window.name = 'Iamparentwindow' 
  3.  
  4.     function openwindow() 
  5.     { 
  6.         var child2 = window.open("Test.htm","childwin","height=350,width=280"); 
  7.         child2.focus(); 
  8.         child2.document.childform.text1.value = 
  9.             document.parentform.testtext2.value; 
  10.     } 
  11. </script> 
  12.  
I have some questions


1. the 3rd line of function openwindow is generating errors- Could you
please help me fix that ?


2. In the child window, I have used
opener.document.parentform.testtext1.value =
document.childform.text2.value;


which is working fine. But I would like to use the name of opener
window, "Iamparentwindow" instead.
Could you please help me?




Thank you in advance
Evrim
Aug 27 '07 #1
7 1719
pbmods
5,821 Recognized Expert Expert
Heya, Evrim.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
  1. What error are you getting?
  2. You can set up a reference by adding this line:
    Expand|Select|Wrap|Line Numbers
    1. var lamparentwindow = window.opener;
    2.  
    However, the parent window's variables are not directly available to the child window except via window.opener.
Aug 28 '07 #2
EvrimAgha
11 New Member
Heya, Evrim.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
  1. What error are you getting?
  2. You can set up a reference by adding this line:
    Expand|Select|Wrap|Line Numbers
    1. var lamparentwindow = window.opener;
    2.  
    However, the parent window's variables are not directly available to the child window except via window.opener.

Thank you for the reply. I will try to stick to the guidelines :-)

This is the error I get :
document.childform.text1 is null or not an object.

However, I should mention that not always I get this error. Sometimes when I hit the refresh button several times and I try to open the child window the value is correctly transferred. But for example if I close the child window and try to open it again I get error.

I am using IE 6 and Win XP Professional. My development tool is NetBeans IDE.

Thanks for your help,
Evrim
Aug 28 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
This is the error I get :
document.childform.text1 is null or not an object.
What does the HTML code for the form "childform" look like?
Aug 28 '07 #4
EvrimAgha
11 New Member
What does the HTML code for the form "childform" look like?

This is the code of the child window page - As you may see I even removed the line that sets the text1.value in childwindow from the parent window and placed it in the child window page --- but no use - So I returned things the way they were .

[HTML]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>

<script language="JavaScript">

function closewindow()
{

opener.document.parentform.testtext1.value = document.childform.text2.value;

window.focus();
window.close();

}
</script>
</head>


<body>

<h3> Testing with JS pass </h3>

<form method="POST" name="childform">

This is filled from parent <Br>
<input type="text" name="text1" value="" /> <BR>
Filled back to parent <Br>
<input type="text" name="text2" value="" /> <BR>

<input type="button" value="Select" onclick="closewindow()"/>
</form>
</body>
</html>[/HTML]
Aug 29 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
This is the error I get :
document.childform.text1 is null or not an object.
The reason why you get this error is that the window has not fully loaded, so the child form is not yet accessible. Run the code onload.
Aug 29 '07 #6
EvrimAgha
11 New Member
The reason why you get this error is that the window has not fully loaded, so the child form is not yet accessible. Run the code onload.
Thank you :-)

you are right , I put the code in onload and it worked .
Aug 31 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Glad you got it working. Post again anytime if you need some assistance.
Aug 31 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
0
by: Neelima Godugu | last post by:
Hi All, I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings requirement inorder to do the above. I have...
7
by: Wade Wegner | last post by:
Hello, I have been desperately trying to programmatically authenticate a windows user, create their credentials, and then redirect them to a different server while passing the credentials at the...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
3
by: Rune Jacobsen | last post by:
Hi all, I am working on my single instance application that now also has a URL type associated with it, according to the Asynchronous Pluggable Protocols information from MSDN. Now, if my...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
3
by: ajaymohank | last post by:
hello everyone..... i am ajay and i am new to php. in my project i have an option to invoke a bat file by passing parrameters and to diplay the result. i tried this code but my page got hung or...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.