Forum Moderators: open
function submitForms()
{
this.document.form1.submit();
this.document.form2.submit();
this.document.form3.submit();
}
function submitForms()
{
this.document.form1.submit();
submitForm2();
}
function submitForm2()
{
this.document.form2.submit();
submitForm3();
}
function submitForm3()
{
this.document.form3.submit();
}
function submitForm1()
{
this.document.form1.submit();
}
function submitForm2()
{
this.document.form2.submit();
}
function submitForm3()
{
this.document.form3.submit();
}
ACTION="javascript:submitForm1();javascript:submitForm2();javascript:submitForm3();"
function submitForms()
{
this.document.form1.submit();
alert('one');
this.document.form2.submit();
alert('two');
this.document.form3.submit();
}
I'd really like to find a better way. Any other ideas?
[blue]this[/blue] refers to the window. I agree it that [blue]this[/blue] should be got rid of anyway, as its unnecessary. Other than that, I'm out of my little envelope. How can more than one form be submitted at the same time? Doesn't the page reload when a form is submitted?
I watch, wait, and hope to learn.
Bernard makes a good point here. By submitting a form you are passing it's data (via the POST or GET method) to a script (generally server side) that processes the information.
Submitting a form triggers an HTTP transfer and a page refresh (even if the form is being sent to the same page).
HTH
<edit>Welcome added</edit>
[edited by: BlobFisk at 2:14 pm (utc) on June 5, 2004]
[blue]this[/blue] out. But I still have the problem of form submission. I am not following you on the page reload. Are you saying that when the page is reloaded, then the page doesn't know that it still has a form submission pending? If so, that seems to make sense to me. But I still don't understand why only the last form in the chain is submitted (or rather the ACTION of only the last form in the chain is executed) but not the first, and why inserting those alerts would have any effect.
I believe the reload on forms submission is a soft reload which doesn't clear the form fields. Else, there wouldn't be the problem of forms being submitted repeatedly by people clicking on the submit button over and over. Therefore, I don't think the reload is a factor.
Unfortunately, the submit() method doesn't fire the onsubmit handler, nor does it return anything that could be used as a test before moving to the next command. It looks like the only approach will be to craft your function to povide an adequate timeout interval between calls to submit(). A kludge, to be sure.
An outside possibility would be if between calls to submit() you used the DOM to set the action through JavaScript (document.formName.action = "http://www.yourURL.com"). That might just gum the works the right amount to get everything to process smoothly. Unfortunately, with either work-around, you'll need to do some testing of different browsers on different speed machines, to make sure either your timeout values are sufficient or that the assignment of the action works cross-platform (if it works at all).
Remember, simply assigning the form to a variable name is a reference, not a copy of the object. Also be aware that if the user closes the browser session, thinking the forms have been sent already, you could lose data. You may wish to implement some sort of a dialog that informs the user the forms are in process, then notifies them when the process is complete.