/    Sign up×
Community /Pin to ProfileBookmark

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

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

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 13.2005 — ... is it possible for them to share fields?[/QUOTE]
No. The other solution is to use a single form but to change the form ACTION depending up which submit button is clicked:

<input type="submit" ... onclick="this.form.action='myformail.php';return true;">

<input type="submit" ... onclick="this.form.action='www.paypal.com';return true;">
Copy linkTweet thisAlerts:
@CharlesApr 13.2005 — However, since one in ten people do not use JavaScript you need to give your FORM element an "action" attribute set to some default handler that will redirect the request as needed. But once you have that you don't need the JavaScript.
Copy linkTweet thisAlerts:
@EchostormauthorApr 14.2005 — Please give me an example of this Charles?
Copy linkTweet thisAlerts:
@phpnoviceApr 14.2005 — What he doesn't tell you is that you'll need server-side code to do that. If you have access to server-side code, then set your form ACTION to go to that page. That page can test which submit button was clicked and pass the form field contents on to the desired target. It is not as easy as he makes it sound. ?
×

Success!

Help @Echostorm 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...