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

How do you access child window data from the parent window?

I have this onclose function for a window that in it it is suppose to grab data from the child window and store it the parent the parent then sends it via ajax to and jsp to store the data in a database. The code is shown below

Expand|Select|Wrap|Line Numbers
  1.  
  2. var auditpop;
  3.  
  4.  
  5.  
  6.     function auditPopup(){
  7.         var map = {"userid" : temp_user};
  8.         jQuery.ajax({
  9.             type: "GET",
  10.              url: '/auditwizard-portlet/checkInProgress.jsp',
  11.              dataType: "html",
  12.              data: map,
  13.              global: true,
  14.              success: function(responseHTML){
  15.                  var audit_war = "/auditwizard-portlet/view.jsp?userid=<%out.print(users);%>";
  16.                 auditpop = dhtmlmodal.open("auditbox","iframe",audit_war,"Athena Audit Wizard","width=1180px,height=700px,scrolling=1,center=0,top=5px,left=5px");
  17.                 auditpop.onclose =    function(){var audit_data = auditpop.document.getElementById("audit_main_div").innerHTML;
  18.                                                 var map = {"app" : auditpop.auditedApp
  19.                                                               , "user" : <%out.print(users);%>
  20.                                                               , "time" : auditpop.timestamp
  21.                                                               , "data" : audit_data};
  22.                                                 var save_url = "/auditwizard-portlet/SaveAuditToDB.jsp?random="+Math.floor(Math.random()*1000);
  23.                                                 jQuery.ajax({type: "GET",url: save_url,dataType: "html",data: map,global: true,
  24.                                                     success: function(responseHTML){
  25.                                                         alert("Save Successful");
  26.                                                     },
  27.                                                     error: function(xhr, status, e){
  28.                                                              if(xhr.status ==500){
  29.                                                                      alert("Please Contact Athena with error description");
  30.                                                              }else if(xhr.status == 404){
  31.                                                              }else{
  32.                                                                  alert("Error has occured with "+xhr.status);
  33.                                                              }
  34.                                                      }
  35.  
  36.                                                 });
  37.                                                 };                
  38.              },
  39.              error: function(xhr, status, e){
  40.                  if(xhr.status ==500){
  41.                      alert("Please Contact Athena with error descript");
  42.                  }else if(xhr.status == 404){
  43.                  }else{
  44.                      alert("Error has occured with "+xhr.status);
  45.                  }
  46.              }
  47.          });
  48.  
  49.  
Can anyone tell why this isn't working and/or how to fix it?
Feb 21 '12 #1
5 6636
Dormilich
8,658 Expert Mod 8TB
what part exactly isn't working?
Feb 22 '12 #2
The section of code in the onclose function where it is trying to gather information from the child window (auditpop). Mainly thr section of below.

Expand|Select|Wrap|Line Numbers
  1. {var audit_data = auditpop.document.getElementById("audit_main_div").innerHTML;
  2.                                                 var map = {"app" : auditpop.auditedApp
  3.                                                               , "user" : <%out.print(users);%>
  4.                                                               , "time" : auditpop.timestamp
  5.                                                               , "data" : audit_data};
  6.  
I have tried using alert to send back what it is getting and it keeps returning undefined. And before anyone asks (not meaning to be rude with my wording) yes the names of the div and the variables are correct, I have checked multiple times on that.

Can anyone tell why this isn't working?

Oh and the code it running in IE8 (if that helps)
Feb 22 '12 #3
Dormilich
8,658 Expert Mod 8TB
Oh and the code it running in IE8 (if that helps)
does it work in Firefox or Chrome?
Feb 22 '12 #4
I haven't checked because the overall application is only meant to run in IE. I used this site

http://www.codeproject.com/Articles/...window-or-vice

and it got to the point i am right now. But still it doesn't seem to work. Could it be that the child window is an iframe or something?

Also, I have my internet options set to allow almost anything and everything to occur for development purposes.
Feb 22 '12 #5
I think I have found the solution. It has to do with the fact that I am using dhtmlmodal window object. I cannot directly reference the window object (auditpop) in the onclose function instead i have to define it in reference to its content so i had to replace the auditpop in the onclose function with this.content. ...

Thank you for your replies.
Feb 22 '12 #6

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...
1
by: zEE | last post by:
How to close all the child windows when parent window get closed? in ASP.net application through scripting..
4
by: hashya | last post by:
Hi, I am trying to submit form in child window from parent window itself. However, not getting through it. e.g. Parent Window: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
1
by: wlevins | last post by:
I have a simple script which has worked flawlessly for years - it copies a bit of data from a child window down into a form field in the parent window that opened the child. But now in Firefox 2.0...
1
by: kumuda v | last post by:
Hello all, I am new to web programming.I have an issue that has to done using javascript and php. How can I pass the data from child window to parent window. I have already written the...
1
by: honey99 | last post by:
Hi! i have a same combobox in parent window and child window.If i enter a value in combobox in child window it should automaticall update in parent window without refreshing the parent window page.I...
5
by: BibhuAshish | last post by:
Hello, I have one child window. in child window i am selecting one radio button. i want to return that selected value to parent window. To open child window in parent window, i have written like...
3
by: Ravigandha | last post by:
Hi every one. I am developing a online movie tickets website. And im struck at this point. I have a link when on clicking the link a pop window opens where in that how to display all the check...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.