Close browser window and redirect

Aleks
Aleks used Ask the Experts™
on
I have a page that opens a browser window, it displays a form that the user fills out.  When the user finishes they simply click the upper right corner of the window to close it. The problem is when they do that I need for the main page which has the link to open it to REFRESH. Because when they save the form displayed in the pop up an entry is made in the database and if they want to open it again the main page needs to be refreshed to pass on the new parameter.

How can I close the pop up window AND refresh my main page when they do ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017

Commented:
Do you use Ajax/Jason?
Does your form page include a submit which you can use to record the data, close the window (some will be promoted to confirm) and in change the main page will refresh.

Author

Commented:
The forms code is generated by a provider, so I cannot touch it. We can however configure adding buttons. I can add a button with javascript that would close the window and then refresh the parent window.
IF I do this I need to take out the "X" close button of the browser window, otherwise user might click on that and adding a button has no purpose.
Distinguished Expert 2017

Commented:
my guess the user hits close, because there is no other option there.
You could add JavaScript validation that triggers the submit when all the form fields are filled in. I.e. Each field onChange trigger a check to see whether the form is complete. Providing the user with a submit button will remove the need of the user closing the window by them selves. Also when you open a separate window, your main page could keep /detect the event when the window is closed.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
That wouldn't work. Saving the form doesn't mean the user is done with the form, forms can be 20 pages long so they fill one page or a few fields and then save it.
when they CLOSE the form then that is when it should close and refresh the parent page.
Distinguished Expert 2017

Commented:
You can look at the example dealing with opening a new window while handling the close event.

http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
The examples pops a notice to the user, a similar mechanism could be a response to the parent page who opened the window to refresh.

The open window you will have onSubmit do things, then window.close.
.

Test out a parent that opens a window, then displays the window closed in the parent window.

Author

Commented:
Thanks you. This might be useful. I will read it tomorrow.
Distinguished Expert 2017

Commented:
If there form/data collection spans 20 pages, presumably each stage is saved, while the data is built-up.............

Handling of the data collection............

Author

Commented:
nop. they save whenever they want. they could save after entering two fields or 10, its up to the user to decide when they want to save their work.
Distinguished Expert 2017
Commented:
W'll resume this after you review the example.  Understanding  the process used in the form/data collection could help I.e. When a firm field is updated, it is reported back to the server and saved......
Tge user can terminate their entry when they want and can resume it in the same way.  Does the main page track how far along the person is?

Author

Commented:
We are trying a different approach.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial