Solved

Refresh Parent window after opening a child window and submitting

Posted on 2003-10-27
8
964 Views
Last Modified: 2012-06-27
Hello gurus,

The situation is that I have a list page (parent page) with a list of items that the user wants to print. Once he selects all the items and clicks 'Print' on the list page, I open a child window, submit the request to the backend, change the modified timestamp for all the selected records in the database and get back the response and show it to the user. After that I want to refresh the parent window with the last modified date for all the selected items....

The problem is that the backend process might take any amount of time and I have to refresh the parent page only when I get all the data back....Can anyone suggest how I can achieve this ? I have tried putting a wait time after submitting but that doesnt seem to work...Here is the relevant code...Please help...

-----------------------------------
CHILD WINDOW
------------------------------------
  if (IE5)
    _wPrint = window.open('', PRINT_POPUP_NAME, 'scrollbars=yes,height='+PRINT_POPUP_HEIGHT+',width='+PRINT_POPUP_WIDTH+',left=100,top=100,resizable=yes,status=no,toolbar=no,directories=no,menubar=no', false);
  else
    _wPrint = window.open('', PRINT_POPUP_NAME, 'scrollbars=yes,height='+PRINT_POPUP_HEIGHT+',width='+PRINT_POPUP_WIDTH+',screenX=100,screenY=100,resizable=yes,status=no,toolbar=no,directories=no,menubar=no', false);
 
  _wPrint.document.write('<html><title>Items</title><P valign="middle" align="center" style="font-family: Arial"><B>Please wait while the page is formatted for printing...</B></P></html>');
  theForm.target = PRINT_POPUP_NAME;
  theForm.method = 'post';
  theForm.submit();


-----------------------------
PARENT WINDOW LOGIC
----------------------------
function printDetails() {
  var f = document.pilistform;
  var numberChecked = 0;
  if (f.detaildata) {
      var itemInfo = "";
            for (var i=0; i<detailData.length; i++) {
                  if(detailData[i].checked) {
                        itemInfo += detailData[i].value + ';';
                        numberChecked++;
                  }
            }
    if (itemInfo.length > 0) {
      f..value = itemInfo.substring(0, itemInfo.length - 1);
      callItemPDFPrint(f, "printitemrequest", "viewprintitemrequest");
      reload_list();
      return;
    }
    alert("Select One Item First");
      }
}

function reload_list() {
      //Logic to reload the parent
}


0
Comment
Question by:prashanth9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 25

Expert Comment

by:devic
ID: 9630206
in popup in body onload call function from parent window
<body onload="opener.reload_list();">

or refresh parent window
<body onload="opener.reload();">
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9630234
The normal way of doing would be that the print output caries a function with it to refresh the parent window.

Are you able to extend the print output with a function for parent window refresh or is this forbidden for you?

If it is forbidden or for any other reason not possible to change the form submit response, then is the only option you have to poll the wait window in a timer interwal and observe wether some detail has changed, for example a global variable in that popup window.

Which method would you prefer: popup polling or response modify?

0
 
LVL 15

Expert Comment

by:JakobA
ID: 9630429
How about placing a target in you form and letting the server generate the new page

<form href="filetogenerateupdatedlist.php" target="nameofparetwindow">

that way the server regulates the update to happen only when the form data have been handeled.

You can give the parentpage (or any window) a name with javascript:
     window.name = ""nameofparetwindow";

regards JakobA
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:prashanth9
ID: 9632984
Netgroove,
I have tried putting in a wait method in my parent window and depending on the number of items that get selected, I used to wait for certain number of seconds before refreshing the parent page but this proved to be unreliable....My items sometimes take very less time and sometimes very long depending on the network and database connections...I didnt understand your questions fully but if you can see the code, I call the child window from my parent window and try to refresh the parent window with logic written in it. I only need logic to make sure that I wait for as long as the child window is done processing before the parent gets refreshed...

Jakoba and Devic,

I will try implementing each of the solutions you have suggested today and see which one works. I had one question however.

How do I make sure that the parent window refreshes only after the child window gets all the content stream from the backend ? The child window might take anywhere between 1 sec and 20 seconds to get the data...I want to refresh my parent window ONLY AFTER all the processing in the child window is done.

Can anyone shed some light on this and let me know how to make sure this happens ?

Thanks
0
 
LVL 25

Expert Comment

by:devic
ID: 9633032
prashanth9,

ONLY AFTER all the processing in the window is done, come EVENT ONLOAD
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10346038
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0
 

Author Comment

by:prashanth9
ID: 10348245
I cannot accept any of the above answers as none of them worked for me. I implemented this logic using a different technique where I catch a Javascript Exception. Refer to this link to see how I solved the same problem :

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20791330.html

So, no points to anyone here.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 10377130
PAQed, with points refunded (125)

Computer101
E-E Admin
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question