Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

forms & submit button question 1

Status
Not open for further replies.

FOXPROG

Programmer
Jan 14, 2001
51
0
0
US
Can I have multiple forms on a page but only have one submit button that posts the input of all forms? If so how do I do it. Will it matter if some of the forms are not displayed when others are?

Thanks
Frank
 
No, I don't think you can have one submit type for different forms. But you can set up a function by JavaScript to put parameters from different forms into one single URL
function tosend() {
a=document.firstform.fieldone.value;
b=document.secondform.fieldtwo.value;
blah,blah,blah
document.location.href="anotherpage.htm?form1value="+a+"form2value="+b+.....
}
You might need to find the number of forms from the page first and generate a loop instead of hard code the forms' properties.

Regards
 
Not sure that you can!

What you can do, depending on what you really want to do is make one really big form. So that the form tag runns from the top of the page to the bottom. Doing this you will then be able to offer one submit button which will work for the page and you can then add form elements all over the page. This is the only way to get around this using HTML?

Hope this helps - even if you did have one button for say two forms the information from the forms would be done in the same action!

hope this helps
 
Yes you can do it.
<script language=&quot;javascript&quot;>
function send(){
form1.submit();
form2.submit();
}
</script>
</HEAD>
<BODY>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;wheretosend&quot;>
<input type=&quot;text&quot; name=&quot;name&quot;>
</form>
<form name=&quot;form2&quot; method=&quot;post&quot; action=&quot;wheretosend&quot;>
<input type=&quot;text&quot; name=&quot;last&quot;>
</form>
<form>
<input type=&quot;button&quot; name=&quot;submit&quot; value=&quot;submit&quot; onClick=&quot;send()&quot;>
</form>

However if you send as an email, it will send two. So I don't know what the effect would be if you were sending it to a page or script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top