473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Passing element values from parent window to child popup window and vice-versa

Hi,
In my application, I call one popup winodow by using this link..

[HTML]<a href="#" onClick="return showWindow('1','XYZ');">
<img src="images/magnifier.gif" ALT="Chemicals" width=18 height=20 border=0>
</a>[/HTML]

In this showWindow function....
Expand|Select|Wrap|Line Numbers
  1.  
  2.   var newWindow = '';
  3.   var url='jsp/DEPO/Chemicals/ProductConfigTabs.jsp';
  4.  function showWindow(data1, data2)
  5.    {
  6.     if (!window.focus){return true;}
  7.     if (!newWindow.closed && newWindow.location)
  8.     {
  9.         newWindow.location.href = url;
  10.     }
  11.     else
  12.     {  
  13.           newWindow=window.open(url+'?abc=ABC&Id='+data1,'NewWin','toolbar=no,status=yes,width=520,height=440');    
  14.         if (!newWindow.opener) newWindow.opener = self;
  15.         //Set value into Child window element.
  16.         setTimeout("SendToChild('" + data1.toLocaleString() + "','" + data2.toLocaleString() + "')",20);
  17.         if (window.focus){newWindow.focus();}
  18.  
  19.     }
  20.    }
  21.  
  22.    //Pass value to child window..
  23.    function SendToChild(data1,data2)
  24.    {
  25.     //Set Hidden value into child Window
  26.      newWindow.document.getElementById("hiddenDivId1").value=data1;
  27.         newWindow.document.getElementById("hiddenDivId2").value=data2;
  28.    }
//In child window JSP i use this div for storing parent window passed values.

[HTML] <div id='hiddenDivId1'></div>
<div id='hiddenDivId2'></div>
[/HTML]
** But Some time i can access this hidden div of child window and some time not..
Please help me to pass parent window element values to child and vice-versa Or Any other way to pass value,
like what i did with url, by using parameter.. please check is this way correct to pass and get value in request

[HTML]<input type="hidden" name="Id" id="Id" value="<%=request.getParameter('Id')%>">[/HTML]

Please use code tags when posting code - moderator

I dont know what i am doing wrong in it. please help me in this problem.

Thanks,
Gajendra
Jul 20 '07 #1
1 17513
acoder
16,027 Expert Mod 8TB
Move the declaration of newWindow outside the function to make it a global variable. If you need to reset it, do not use the var keyword.

When trying to set the content in a div, "value" won't work. Use innerHTML instead or create a text node and append it to the div.

To access the parent from the child, use window.opener.
Jul 20 '07 #2

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

Similar topics

4
by: Earl Teigrob | last post by:
I am thinking about using a popup window to edit settings that will affect parent asp.net page. The data that is changed in the popup window will be saved to the datastore that is loaded and...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
1
by: Paul D. Fox | last post by:
I'm trying to launch a Child Window from a hyperlink on a Datagrid and have it recieve multiple values from the Parent Window. Upon recieving the values in the Child Window, I need to access them...
3
by: Aaron | last post by:
I am having a little difficulty with a relatively simple task. I have a parent webform. I have a javascript attribute added to a button to open a new window when clicked. The user fills in a...
2
by: Robert Degen | last post by:
Hello, I got a little problem. Seems very simple: * I want to open a popup window * Popup-window uses data from its father window. BUT a parent.window does NOT point to the real parents...
5
by: midnight_use_only | last post by:
hi all, quick question, how do you submit a form to a parent window from a child popup window? i have the following and all online documentation *suggests* that it should work but it does NOT: ...
1
by: neena | last post by:
anyone please tell me how to pass the selected value from a listbox in popup window(child window) ,created using window.open() in javascript ,to a textbox in parent window please help me...
2
by: sanscrimson | last post by:
Hi! I just want to ask if it possible to call functions in parent window if the child window is created. Below is sample:...
5
by: TurboRogue | last post by:
So here's the basic premise: I have an html page with a bunch of pictures (pic.html). All of the images are thumbnails of larger photos. I also have another html page which is a pop-up window...
1
by: srinivasyadavkota | last post by:
Hi Experts here, Pls help. In my WebApplication from Home page(i.e parent window) i am sending the values to child window(i.e popup page) In the popup page(i.e child window) I am storing the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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...

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.