Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6188423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:13:43+00:00 2026-05-24T02:13:43+00:00

I have a basic html form which I want to use with two submit

  • 0

I have a basic html form which I want to use with two submit buttons. The CGI script takes the form value and processes it (regardless of which submit button used), but I want each button to be associated with different actions later in the script, i.e. print different output:

##  Get the form value in the usual way.
form = cgi.FieldStorage()
RawSearchTerm = form.getvalue("QUERY")

##  Process the form info etc.

if (button1 was pressed):
    print this
elif (button2 was pressed):
    print this other thing

Any ideas appreciated, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:13:44+00:00Added an answer on May 24, 2026 at 2:13 am
    <input type="submit" value="Submit" name="Submit1" />
    <input type="submit" value="Submit" name="Submit2" />
    

    This will give you a different name in your form data depending on which submit button was pressed.

    You can do

    form = cgi.FieldStorage()
    
    if "Submit1" in form:
        button = 1
    elif "Submit2" in form:
        button = 2
    else:
        print "Couldn't determine which button was pressed."
    

    because form acts like a Python dict and you can check if a given name is in it. It should include the names of all form entities sent, so, with one field and two submit buttons, it should contain the name of the form field and the name of the submit button that was pressed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic HTML form that gets inserted into a server side div
I have a basic ActiveRecord model in which i have two fields that i
How can I use HTTP basic Authentication and have the user submit their Username
I have a basic page set up online on my server which processes Post
I have a basic login form, which uses ajax to login users. If the
I have an order form on which I use the jQuery Calculation Plugin to
Starting out with php, I have written a basic authentication script which prints out
I've got a basic HTML form from which I can grab a bit of
I have an html form which inserts data into a database. I just built
Currently, i have basic C++ and PHP skills. But, i want to switch to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.