469,271 Members | 1,718 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

button click to submit two seperate forms

Hi all

is it possible to onclick of a button in one form submit that form and
also submit another form on the same page, both with the same 'action'
location? or is it only possible to send one at a time?

kind regards

Marc

Aug 6 '06 #1
3 4557
Rik
libsfan01 wrote:
Hi all

is it possible to onclick of a button in one form submit that form and
also submit another form on the same page, both with the same 'action'
location? or is it only possible to send one at a time?

AFAIK you can only submit one form, but nothing stops you to add the values
from the one as hidden values in the other at the onsubmit event.

Grtz,
--
Rik Wasmus
Aug 6 '06 #2
libsfan01 wrote:
Hi all

is it possible to onclick of a button in one form submit that form and
also submit another form on the same page, both with the same 'action'
location? or is it only possible to send one at a time?

kind regards

Marc
<button onClick="submitForms()">submit</button>

function submitForms() {
document.form1.submit();
document.form2.submit();
}

only problem I personally have with this method is this, in <formtag

onSubmit="return submitForm(this)"

gets ignored.. you can also do 'submit' button with an image, thus:

<input type="image" src="send.jpg" border=0
onMouseOver="this.src='send_roll.jpg'" onMouseOut="this.src='send.jpg'">

this works because when you do "input type=image" it defaults to
'submit' type... (and as you can see you can also do a rollover for
it..) I have not found a way to do it like this for 'reset' button, so
for 'reset' button I do

<img src="reset.jpg" onClick="resetForms()" border=0
onMouseOver="this.src='reset_roll.jpg'" onMouseOut="this.src='reset.jpg'">

reset function:

function resetForms() {
document.form1.reset();
document.form2.reset();
}

I wonder if anybody here can tell me how to do this with a <buttonso
call to validation function in <formtag isn't ignored?

Aug 6 '06 #3
maya wrote:
<button onClick="submitForms()">submit</button>

function submitForms() {
document.form1.submit();
document.form2.submit();
}
The second form submission will cancel the first one (unless the browser
leaves the page soon enough to never reach the second one).
only problem I personally have with this method is this, in <formtag

onSubmit="return submitForm(this)"

gets ignored..
Yes. The onsubmit event fires when the user submits the form - not when a
script submits the form.
<input type="image" src="send.jpg" border=0
onMouseOver="this.src='send_roll.jpg'" onMouseOut="this.src='send.jpg'">

this works because when you do "input type=image" it defaults to
'submit' type...
No. Image inputs submit forms, but they aren't "the submit type"
--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Aug 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Chris L | last post: by
4 posts views Thread by Dmitry Korolyov [MVP] | last post: by
11 posts views Thread by CW | last post: by
29 posts views Thread by Tom wilson | last post: by
3 posts views Thread by JV | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.