Post multiple forms

F

Fabri

Is it possible to post all (or more of one) forms simultaneosly?

document.forms.submit?

Any help appreciated.

Regards.
 
M

McKirahan

Fabri said:
Is it possible to post all (or more of one) forms simultaneosly?

document.forms.submit?

Any help appreciated.

Regards.

I don't think you can. I tried the following:

<html>
<head>
<title>submit2.htm</title>
<script type="text/javascript">
function submit2() {
document.form1.submit();
alert(1);
document.form2.submit();
alert(2);
}
</script>
</head>
<body>
<form action="submit2.htm" method="get" name="form1">
<input type="text" name="text1" value="1">
</form>
<hr>
<form action="submit2.htm" method="get" name="form2">
<input type="text" name="text2" value="2">
</form>
<hr>
<input type="button" value="Submit Forms" onclick="submit2()">
</body>
</html>
 
M

Martin Honnen

Fabri said:
Is it possible to post all (or more of one) forms simultaneosly?

Well probably only if the target is set differently or to a new window e.g.
for (var i = 0; i < document.forms.length; i++) {
document.forms.target = '_blank';
document.forms.submit();
}
If you have forms with no target set then obviously submitting one means
unloading the current page and then there are not further forms to submit.
 
F

Fabri

Martin said:
Well probably only if the target is set differently or to a new window e.g.
for (var i = 0; i < document.forms.length; i++) {
document.forms.target = '_blank';
document.forms.submit();
}



AWESOME!!!!!!
 
R

rf

Martin Honnen said:
Is it possible to post all (or more of one) forms simultaneosly?

Well probably only if the target is set differently or to a new window e.g.
for (var i = 0; i < document.forms.length; i++) {
document.forms.target = '_blank';
document.forms.submit();
}


Which will result in a plethora of new windows popping up.
If you have forms with no target set then obviously submitting one means
unloading the current page and then there are not further forms to submit.


Why not just cause the server side form handler to return, say, a 204, there
is no new information to send back? That way the existing page will remain.
 
F

Fabri

rf wrote:

[CUT]
Why not just cause the server side form handler to return, say, a 204, there
is no new information to send back? That way the existing page will remain.


Can you give us an example please?

Regards.
 
R

rf

Fabri said:
rf wrote:

[CUT]
Why not just cause the server side form handler to return, say, a 204, there
is no new information to send back? That way the existing page will
remain.

Can you give us an example please?

You are probably better off asking over in the server side groups. alt.php,
comp.lang.php, or whatever flavour of server side stuff you use.

Here is a minimal PHP example:

In your "page"

<form action="updatedatabase.php" ...>
....

In updatadatabase.php:

<?php
header("HTTP/1.0 204 No Response"); // terminates this HTTP request
// do stuff with the data sent up by the form
// do not output any "content" for this request. That is, no html.
// the sole purpose of this "page" is to update a database or something.
?>

Google for: php 404 header
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top