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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submitting info from many forms at once

Status
Not open for further replies.

quextion

Programmer
Mar 11, 2002
1
GB
hi!

i wonder if anyone can help me with this problem.

i need to post the info from the forms (10 of them!) on my page at once. i'd like to do this from a function that could be called by any of the submit buttons on the page.

i think the best way to do it is to collect the info into a string which is then made equal to a hidden field which is posted with any of the forms.

i'm open to any ideas though.

i have to post the data as it will frequently contain more than 255 chars, so a get won't do.

i'm new to javasript so there may be some inconsistency in my code, but here's the general idea>>

Code:
<script language=&quot;JavaScript&quot;></script>
<!--
function StoreFormData(){

for ( k=0, k < 10; k++){ %> //loop for each of the ten forms on the page

f = &quot;form_block&quot;+String.valueOf(k)  // make jscript variable = to the name of the form

for(n = 0, n < f.elements.length; n++){ //loop through each of the elements in the form

stringbuff+=f.elements.value;
}

}
}


then i need to make the stringbuff equal to a form variable and send it out. i'm really not sure how to do this.

thanks in advance for any help.

cheers,

q
 
Try the following.

In your javascript:
Code:
function submitall()
{
document.form1.submit();
document.form2.submit();
document.form3.submit();
}


and your forms:
Code:
<form action=&quot;blabla&quot; method=POST target=&quot;a&quot; name=&quot;form1&quot;>
<input name=&quot;myinput&quot;>
<input type=&quot;button&quot; value=&quot;Submit&quot; onclick=&quot;submitall()&quot;>
</form>

<form action=&quot;blabla&quot; method=POST target=&quot;b&quot; name=&quot;form2&quot;>
<input name=&quot;myinput&quot;>
<input type=&quot;button&quot; value=&quot;Submit&quot; onclick=&quot;submitall()&quot;>
</form>

<form action=&quot;blabla&quot; method=POST target=&quot;c&quot; name=&quot;form3&quot;>
<input name=&quot;myinput&quot;>
<input type=&quot;button&quot; value=&quot;Submit&quot; onclick=&quot;submitall()&quot;>
</form>


So, the the forms are submitted to other frames.
I assume you know how how to make frames...

see also:
 
I am afraid, but submitAll() function won't work as when you form1.submit() function is called, control will go to the next page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top