/    Sign up×
Community /Pin to ProfileBookmark

submitting multiple forms

I am looking to submit data as two independent form submissions from one page and one submit button on that page. Can anyone help with a javascript function along the following lines.

The page would have one form called “referralform”. The page would be contained in the second of two frames. Frame one would be hidden and frame two would contain my page and form.

The form, named “referralform” would have the following fields, named according to their content

firstname
firstname2
lastname
lastname2
email
secondemail
id [this is a hidden field]

The function should accomplish the following:

Copy the contents of the form fields in frame two to specific fields in a form in frame one, and finally submit the form in both frames.

Tha value of the fields in frame 2 would have to be copied or “mapped” to the following values in frame1:

For Frame 1:
firstname goes into field named referrerfirstname
firstname2 goes into field named firstname
lastname goes into field named referrerlastname
lastname2 goes into field named lastname
email goes into field named referreremail
secondemail goes into field named email

Both frames 1 and 2 will submit to the same action.

All help is greatly appreciated.

Thanks.

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@NedalsMar 18.2003 — Both frames 1 and 2 will submit to the same action[/quote]What? ?

Re-stated: You want to submit the contents of 2 forms using a single submit. You can't!

To solve the problem, copy the contents of form2 to form1 and submit form1 (or maybe it's the other way around!!!)
Copy linkTweet thisAlerts:
@jporvenauthorMar 18.2003 — I am aware that a single submit cannot "technically " submit tow forms. hence the use of the hidden frame. The submit button in the page (frame2) would call a javascript function that copies the form values over to frame 1 and then (with a slight timed delay ) submit the form in frame 1, and submit the form in frame 2. So in essence each form is "seperate" (in their own frames) and submitted individually.
Copy linkTweet thisAlerts:
@NedalsMar 18.2003 — You could certainly submit one form followed 'shortly' by the other, but I have no idea what would happen to your data. I'm pretty sure it would not get to the server reliably.

In addition, you would have to make sure that the first post sent a 'status: 204 no-content' return, otherwise your page will dissap...... Wait just a minute!

Frames, eh!

OK! After you have done all your copying etc., submit the form in frame1 and send back a page that has an 'onload' to a script in that will submit the form in frame2. Get it?

Kind of a work around, but it WILL work! ?
Copy linkTweet thisAlerts:
@jporvenauthorMar 18.2003 — Thanks. nedals. I have an idea of how to submit the forms, but am stuck on how to get the data from frame 2 copied to theform in frame 1.
Copy linkTweet thisAlerts:
@NedalsMar 18.2003 — In frame1 (javascript)

document.theform.element-name.value = top.frame2-name.document.thatform-name.thatelemen-name.value
Copy linkTweet thisAlerts:
@napoleonvDec 22.2005 — You can make it so that when they click on the submit button, it will call a function that will submit all the forms. This works for IE. Not sure for any other browser.

<script>

function submitallforms() {

setTimeout('document.forms[0].submit()',100);

setTimeout('document.forms[1].submit()',200);

setTimeout('document.forms[2].submit()',300);

}

// End -->

</script>

<input type=button value="Submit" onclick="submitallforms();">

Napoleon N. Valdez

Senior Web Database Developer

Caspio, Inc.

Toll-free: (877) 820-9100 ext. 703

Local or International: +1.408.970.0500 ext. 703

Fax: 1.408.516.9925

Email: [email][email protected][/email]

http://www.caspio.com
Copy linkTweet thisAlerts:
@adalbyDec 23.2005 — Hello,

I'm very interested in knowing Napoleonv code. What would the form tag look like for this code. Something like this????


<FORM action=/cgi-bin/xxx.pl method=POST name=200>

Thanks,

Aaron
Copy linkTweet thisAlerts:
@napoleonvJan 03.2006 — Hello Aaron,

You can try HTML file below.

<html>

<head>

<script>

function submitallforms() {

setTimeout('document.forms[0].submit()',100);

setTimeout('document.forms[1].submit()',200);

setTimeout('document.forms[2].submit()',300);

}

// End -->

</script>

</head>

<body>

<FORM action=/cgi-bin/xxx.pl method=POST name=200>

Last name: <input type="text" name="Last Name" size=40 value="">

<br>

E-mail Address: <input type="text" name="E-mail Address" size=12 value="">

<br>

</form>

<FORM action=/cgi-bin/xxx.pl method=POST name=200>

Last name: <input type="text" name="Last Name" size=40 value="">

<br>

E-mail Address: <input type="text" name="E-mail Address" size=12 value="">

<br>

</form>

<input type=button value="Submit" onclick="submitallforms();">

</body>

</html>

Let me know how it goes.

Napoleon N. Valdez

Senior Web Database Developer

Caspio, Inc.

Toll-free: (877) 820-9100 ext. 703

Local or International: +1.408.970.0500 ext. 703

Fax: 1.408.516.9925

Email: [email][email protected][/email]

http://www.caspio.com
Copy linkTweet thisAlerts:
@michelle9955Mar 07.2007 — I'm also trying to figure out how to copy between frames. I have the same scenario as above with the 2 frames but I am having a hard time getting the code (the document.theform.element-name.value etc.) to work correctly. Should I be including an onChange or onSubmit button to get it to work. I'm new at some of this and need a little more guidance.

Thanks!
×

Success!

Help @jporven spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...