/    Sign up×
Community /Pin to ProfileBookmark

Form with two buttons

Hi !
Does anyone have an example of a form in which there is two ‘submit’ buttons ??
That is – submit button #1 executes a page or cgi script
and submit button #2 execute a TOTALLY different page or cgi script.

Any examples and/or example code would be appreciated !

thanks – jerry

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@scragarNov 10.2007 — I don't know CGI, so I can't help you too much with that, but if you try the following script and check the URL bar after each submit button you should see the effect.

[code=html]<form action="?" method="GET">
<p><input type="submit" name="submit" value="1" /></p>
<p><input type="submit" name="submit" value="2" /></p>
<p><input type="submit" name="cheese" value="3" /></p>
</form>[/code]

basicly which ever form button submits the form sends it's value, simple check and compair it then redirect acordingly.
Copy linkTweet thisAlerts:
@felgallNov 10.2007 — 
  • 1. don't name your submit buttons "submit" or you break IE6+ which overlays the button reference over the submit function making it impossible to actually submit the form.


  • 2. If you give all the submit buttons the same name then you can test the value that the field contains in the server side script to work out which button was pressed and what to therefore do. That is an easier test than testing if one of several different named fields exists.
  • Copy linkTweet thisAlerts:
    @jerryr125authorNov 10.2007 — hi - basically the "method" will be "post" for either of the two buttons clicked.

    I want to have the action changed based upon the button clicked.

    that is :

    if button1 is click, action1 is executed

    if button2 is click, action2 is executed

    does the make since ? thanks ? jr
    ×

    Success!

    Help @jerryr125 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.7,
    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,
    )...