Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Popups, actions and javascript OH MY!

 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • 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...
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OR you can look into Ajax and avoid the whole pop up situation.
 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic