This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes HTML, CSS and JavaScript and the fly likes Submit form and close window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Submit form and close window" Watch "Submit form and close window" New topic
Author

Submit form and close window

Veni Velkoor
Ranch Hand

Joined: Oct 17, 2001
Posts: 65
Hi,
I would like to be able to submit my form and then close the window when a user clicks the exit button. I tried the following code--
if (k == 3)
{
document.Form1.c__Aid_I.value=k;
document.Form1.submit();
wondow.close();
}
else {
document.Form1.c__Aid_I.value=k;
document.Form1.submit();
}
When the Exit button is clicked the window closes but the form is not submitted prior to the close. it works fine when I remove the window.close() statement.
So now I wonder if the submit form and window.close functions can co-exist?? Any ideas/suggestions would be great!
Thanks,
Veni.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Veni
When you submit a form you have to have an 'action' in the form tag for the form to be submitted to. If you are closing the window then the page the action refers to can not be opened. the data may well be submitted but the user would never know because the window closed.
Dave


Dave
Veni Velkoor
Ranch Hand

Joined: Oct 17, 2001
Posts: 65
Thanks Dave, I'll try looking for the action for the submit.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Submit form and close window