• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Popups, actions and javascript OH MY!

 
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm looking to have a popup window do a submit and then close the window. Can I do this with one javascript action? Has anyone had to do this? Its basically a database update from a popup. The expected result is that when this button is hit, the update will happen and then the window will close.

Your thoughts...
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on the body onload you need to do onload="document.formName.submit()"

use the action to take the form submission to another page. on that page do onload="window.close()"

If you do not want to take it to another page, than you just need to have the server side code write out the close statement to the page.

Eric
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OR you can look into Ajax and avoid the whole pop up situation.
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have done this.

Option 1: Submit the page in the popup. The return page will have either an error message and a close button, or if it successfully submetted, a javascript that will reload the parent and close itself:



Option 2: Have the javascript call a function on the opener.



You might need to hide a form in the opener page. You can also pass attributes with the function call. Then the function sets the values in the opener page and then submits the hidden form.

Option one is what I ended up using. It is cleaner. But it is all up to you on your process flow.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic