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

2 submit buttons 2 forms but same input fields?. :S

Status
Not open for further replies.

echostorm

Vendor
Apr 10, 2005
28
AU
Hey all,
Ive seen people use 2 submits on 1 form. However my dilema is this. I have 2 forms, 2 submits, and 1 set of input fields. I need 2 forms because one is sent to my formail.php and the other is sent to paypal for online ordering. Both of the forms have there own submit button but is it possible for them to share fields?

Echo
 
Because I am usless with php. I have just finished learning javascipt to do this action! I am still not an expert with javascript but I am now familiar. All of the online paypal stuff is operated by a javascript.js file and all of the email stuff is from the formmail.php file. Is it possiple to integrate the 2. I am desperate. I would pay someone to help with this problem is need be.

Echo
 
You'll have to figure out some way to get one of them to submit to the other. There is no way in javascript or html to submit to two different places. As soon as you submit to one place, the browser expects the page to be replaced with a new page.

Actually, there is one way around the problem. Use a hidden frame or iframe to contain one of the forms and use the onsubmit event of one of the buttons to copy the values from one form to the other and submit the other form. If you've just learned javascript this may be beyond your current abilities, but you may find some ideas in other threads here.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I don't really understand Your setup but here's how to
send two forms with one click:

Make the button type=button with
Code:
    onClick="document.thisform.submit();
             document.otherform.submit();"

Note! Remove the line break inside the onClick string !


-- mats
 
PayPal doesn't have an option to e-mail a confirmation? I would have thought differently.

Here's one possible way, but this should really be done with a server-side process:
Code:
function sendIt(){
  document.formName.target='hiddenFrame1'
  document.formName.action='paypalOrWhatever.html'
  document.formName.submit();

  document.formName.target='hiddenFrame2'
  document.formName.action='yourEmailForm.html'
  document.formName.submit();
}

Adam

Whatever I feel like I wanna do, gosh!
 
cLFlaVa,

then both forms are written to the same window!
Probably You ony see one - the last.

Avoid that by setting different target="name" in the forms.

Note that target could be the name of an frame or iframe
so you _can_ have the results in the same main window.

-- mats
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top