Jump to content

submit button for 2 forms?


Splurd

Recommended Posts

Can it be done? basicly I have one form, but since I am doing some JS thing, I want to split it up into two forms.Like,

<form action="sectest2.asp" method="post"><input type="text" name="haha"><br></form><form  action="sectest2.asp" method="post"><input type="text" name="hehe"><br><input type="submit" name="wow" value="Da submit buttan"><br></form>

Link to comment
Share on other sites

Can it be done? basicly I have one form, but since I am doing some JS thing, I want to split it up into two forms.
Yes it can be done, if you give your forms a name then you can submit both with javascript.The javascript
function submitForms() {document.[color="red"]form1[/color].submit();document.[color="blue"]form2[/color].submit();}

The forms

<form action="sectest2.asp" method="post" name="[color="red"]form1[/color]">...</form><form  action="sectest2.asp" method="post" name="[color="blue"]form2[/color]">...<input type="button" value="submit" onclick="submitForms()" /></form>

Link to comment
Share on other sites

are both form's elements available in the POST array? I can see the need for more than one form on a page but what is the point of submitting 2 forms at once? Why not make it one form?

Link to comment
Share on other sites

What would that do?  Would it redirect you to the first or the second form?

You would be directed to the second form and only form2 would actually be processed (i think :) - i done alert() tests and thats what i found)To get round this you could target each form to an iframe which doesn't require you to leave the current page.I have make a javascript test to show that both forms are processed.http://scott100.atspace.com/test.htmAs you can see from the results, when you type in different usernames both forms are processed.
Link to comment
Share on other sites

are both form's elements available in the POST array? I can see the need for more than one form on a page but what is the point of submitting 2 forms at once? Why not make it one form?

because I am going to put id="ect" in the 2nd form to do JS with it, and if I combine the form it makes things somewhat complicated for me, so I was wondering it there was a way to do it. Plus it cant hurt to know if it can be done.I tried scott100's method but it only sumbited the 2nd form. Its weird tho, I put an alert in the script and it processed the first form but not the second. But if I remove the aleart, It will process the 2nd form.(eg, form1.submitalert("hoho")form2.submit)returns the first one. scott100's target thing seems to work, but I think thats besause the forum is submited twice to the pages. eg, form1 gets sumbited to the page, then form2 gets sumbited to another instance of the page. As opposed to form1 and form2 get submited to the page at the same time.
Link to comment
Share on other sites

scott100's target thing seems to work, but I think thats besause the forum is submited twice to the pages. eg, form1 gets sumbited to the page, then form2 gets sumbited to another instance of the page. As opposed to form1 and form2 get submited to the page at the same time.
Yes that's the only way this will work (if you target an iframe), otherwise one form never gets submitted.You don't have to display the iframes, you could set there visibility to hidden. :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...