473,396 Members | 1,599 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,396 software developers and data experts.

passing data from parent window to popup

meenakshia
hi forum
i have read a lot of articles regarding passing data from popup to parent up but i m looking for the opposite
that is
from parent to popup window
pls help me in this regard
i have three input fields in parent window
and three in popup window

parent.htm
Expand|Select|Wrap|Line Numbers
  1.  
  2. <script language="JavaScript">
  3. function newWindow(file,window)
  4. {msgWindow=open(file,window,'scrollbars=yes,resizable=no,width=550,height=400');
  5. if (msgWindow.opener == null) msgWindow.opener = self;
  6. }
  7. </script>
  8.  
  9. <input type="button" value="Search" onClick="newWindow('popup.htm','window2')">
  10.  
  11. <form name="inputform1" >
  12. <table><tr><td>Stitching Number
  13. </td>
  14. <td><input type="text" name="txtasno" tabindex="1"  size="20">
  15. </td>
  16. <td>Remarks
  17. </td>
  18. <td><input type="text" name="txtremarks" tabindex="5"  size="20">
  19. </td>
  20. <td>Sales Person
  21. </td>
  22. <td><input type="text" name="txtsperson" tabindex="6"  size="20">
  23. </td>
  24. </tr></table>
  25. </form>
  26.  
popup.htm
Expand|Select|Wrap|Line Numbers
  1. <form name="outputform1" >
  2. <table><tr><td>Stitching Number
  3. </td>
  4. <td><input type="text" name="txtasno" tabindex="1"  size="20">
  5. </td>
  6. <td>Remarks
  7. </td>
  8. <td><input type="text" name="txtremarks" tabindex="5"  size="20">
  9. </td>
  10. <td>Sales Person
  11. </td>
  12. <td><input type="text" name="txtsperson" tabindex="6"  size="20">
  13. </td>
  14. </tr></table>
  15. </form>
  16.  
i hope there is a way to do this
smile always:)
anand
Jun 27 '08 #1
12 37746
vikas251074
198 100+
How can you pass a value without submitting a form?

I mean, you should have button in the input form. Then you can modify the popup.htm as follows

Expand|Select|Wrap|Line Numbers
  1. <form name="outputform1" >
  2. <table><tr><td>Stitching Number
  3. </td>
  4. <td><%=request.form("txtasno")%>
  5. </td>
  6. <td>Remarks
  7. </td>
  8. <td><%=request.form("txtremarks")%>
  9. </td>
  10. <td>Sales Person
  11. </td>
  12. <td><%=request.form("txtsperson")%>
  13. </td>
  14. </tr></table>
  15. </form>
  16.  
This may help you.

Thanks and regards,
Vikas
Jun 27 '08 #2
hi thanks and yes it was a mistake i made but then the problem is still the same
i need to solve the way to pass data from parent window to popup window
i have modified the code accordingly
Jun 27 '08 #3
vikas251074
198 100+
What is the error message?

Regards,
Vikas
Jun 27 '08 #4
realin
254 100+
hi i dont know if this is going to helpyou or no, but this one is simple sending data from parent window to child window. hope this helps

Parent window code:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6. <title>send data over child window</title>
  7. <script language="javascript" type="text/javascript">
  8. var winRef;
  9. function open_win(){
  10. winRef=window.open("child.htm");
  11. }
  12.  
  13. function send_data(){
  14. var g=document.getElementById("_text").value;
  15. winRef.document.getElementById("_child").value=g;
  16. }
  17. </script>
  18. </head>
  19.  
  20. <body>
  21.  
  22. <a href="javascript:void(0);" onclick="open_win();">open window</a><br />
  23. <input type="text" name="_text" id="_text" /><br />
  24.  
  25. <a href="javascript:void(0);" onclick="send_data();">Send data</a>
  26. </body>
  27. </html>
  28.  
Child Window Code:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <input type="text" name="_child" id="_child" value=""/>
  11. </body>
  12. </html>
  13.  
cheers !!
Jun 27 '08 #5
acoder
16,027 Expert Mod 8TB
How can you pass a value without submitting a form?

I mean, you should have button in the input form. Then you can modify the popup.htm as follows...
You can pass values without submitting a form. The code you posted assumes the data was posted and just displays it using ASP. Since there are no input fields, there's no need for the form tag.

Also, don't forget to use code tags when posting code.
Jun 27 '08 #6
acoder
16,027 Expert Mod 8TB
i have read a lot of articles regarding passing data from popup to parent up but i m looking for the opposite
that is from parent to popup window
realin has posted code which you should be able to adapt to your requirements. Remember though that the popup window will not be available immediately, so you will need something to trigger the passing of value, e.g. a button.

Finally, the language attribute of the script tag is deprecated - use type="text/javascript" instead.
Jun 27 '08 #7
hi realin
thanks for the help and yes it is working fine
only thing that i require more is that is it possible to open the new window and copy the data with only link click?
or i have to do it this way only?
thanks
anand
Jun 28 '08 #8
acoder
16,027 Expert Mod 8TB
You can do that, but you will need to use a timeout to check for the existence of the window. When it's ready, you can pass the data. An alternative is to call the function in the parent from the popup body onload.
Jun 28 '08 #9
realin
254 100+
hi realin
thanks for the help and yes it is working fine
only thing that i require more is that is it possible to open the new window and copy the data with only link click?
or i have to do it this way only?
thanks
anand
hiya,

well i guess u can call the send_data() function inside the other, ofcourse u can use setTimeout() so as to avoid any sorta problem. But if also integrated a check for the child window, meaning if the child window doesnt exist, it will alert the user and then it won't try to transfer data. Look at the modified code, nevertheless the childwindow code remains the same.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  
  3.    <html xmlns="http://www.w3.org/1999/xhtml">
  4.  
  5.    <head>
  6.  
  7.    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  8.  
  9.    <title>send data over child window</title>
  10.  
  11.    <script language="javascript" type="text/javascript">
  12.  
  13.    var winRef;
  14.  
  15.    function open_win(){
  16.  
  17.    winRef=window.open("popup.htm");
  18.   send_data();
  19.    }
  20.  
  21.  
  22.  
  23.    function send_data(){
  24.   if(winRef==null){
  25.   alert("Child window doesn't exist");
  26.   return false;
  27.   }
  28.   else{
  29.    var g=document.getElementById("_text").value;
  30.  
  31.    winRef.document.getElementById("_child").value=g;
  32.    }
  33.  
  34.    }
  35.  
  36.    </script>
  37.  
  38.    </head>
  39.  
  40.  
  41.  
  42.    <body>
  43.  
  44.  
  45.  
  46.    <a href="javascript:void(0);" onclick="open_win();">open new child window and send data</a><br />
  47.  
  48.    <input type="text" name="_text" id="_text" /><br />
  49.  
  50.  
  51.  
  52.    <!--<a href="javascript:void(0);" onclick="send_data();">Send data</a>-->
  53.  
  54.    </body>
  55.  
  56.       </html>
  57.  


cheers !!
Jul 3 '08 #10
Hello Friends !!

I have read all the above posts and seems interesting.
I have one query for the above post.
you are passing values from parent to child window. and now i need to pass the same values that are used in above code to passed back to parent window in a new text box thru child window using a link on child windows elements.

Can anybody help me regarding this.


Thanks in advance.

Regards,

Sneha
Jul 25 '08 #11
acoder
16,027 Expert Mod 8TB
Hi Sheha, welcome to Bytes.

Use window.opener to refer to the parent from the child window.
Jul 29 '08 #12
To open the child window this is the code used in parent window
Expand|Select|Wrap|Line Numbers
  1. <form method=post action='' name=f1>
  2. <table border=0 cellpadding=0 cellspacing=0 width=550> <tr>
  3. <td ><font size=2 face='Verdana'>Your Name</font><input type=text name='p_name' size='8'> 
  4. <a href="javascript:void(0);" NAME="My Window Name" title=" My title here "
  5. onClick=window.open("child3.html","Ratting",
  6. "width=550,height=170,left=150,top=200,toolbar=1,status=1,");>Click here to open the child window</a>
  7.  
  8. </td></tr> </table></form>
  9.  
Inside the Child window code is here
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. <script langauge="javascript">
  5. function post_value(){
  6. opener.document.f1.p_name.value = document.frm.c_name.value;
  7. self.close();
  8. }
  9. </script>
  10.  
  11. <title>(Type a title for your page here)</title>
  12. </head>
  13.  
  14.  
  15. <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
  16.  
  17. <form name="frm" method=post action=''>
  18. <table border=0 cellpadding=0 cellspacing=0 width=250>
  19.  
  20.  
  21. <tr><td align="center"> Your name<input type="text" name="c_name" size=12 value=test> <input type=button value='Submit' onclick="post_value();">
  22. </td></tr>
  23. </table></form>
  24.  
Oct 25 '10 #13

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

Similar topics

4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
5
by: Peter | last post by:
1) I have a C# web application and what I am trying to do is create a popup window from a link on the parent window 2) the popup window will have a button and when a user clicks on the button the...
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...
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: pingalkar | last post by:
Hi, In my application, I call one popup winodow by using this link.. <a href="#" onClick="return showWindow('1','XYZ');"> <img src="images/magnifier.gif" ALT="Chemicals"...
6
by: backups2007 | last post by:
What I want to do is be able to open a popup window that may pass data to different rows of textboxes of its parent window. I want to pass data to different rows of textboxes and each row has a...
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...
2
by: Cessaar | last post by:
Hi masters, (excuse my english) I hope you could help me with this... I´m working with visual studio 2005 on IE7 (I think this the origen of my problem because on IE6 worked fine)...and I'm...
10
by: perhapscwk | last post by:
how to passing value from popup to the parent window as a variable which I can access and process the variable(string) in parent window? such as from popup page, we have var_from_popup="abc",...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.