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 873321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:54:57+00:00 2026-05-15T10:54:57+00:00

What I want is to be able to make my CGI script do different

  • 0

What I want is to be able to make my CGI script do different things depending on what action initiated the calling of the script.

For example, if one button is pressed, a database is cleared. If another button is pressed, a form is submitted and that data is added to the database.

Should I be doing something like adding the name of the form/button to the end of the POST data submitted in jQuery and then .poping it off in the script?

Or is there some other data that’s already sent in the POST that I could get from FieldStorage that would give me the information I need to decide what the script should do when it’s called?

And what if I wasn’t using javascript? Would I have to have a hidden field that gets submitted with the name of the form/button?

Or is it best to use a different target script for each button on a page?

  • 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-15T10:54:58+00:00Added an answer on May 15, 2026 at 10:54 am

    POST request includes all the elements of the form you submit. So, if you have a form with several submit buttons:

       <form id="mytestform" target="/cgi-bin/script.py" method="POST">
         <input type="submit" name="ClearDB" value="Clear DB"/>
         <input type="submit" name="TestDB" value="Test DB"/>
         <input type="text" name="hostname" />
       </form>
    

    then you would get a POST request with request data looking like: ClearDB=Clear%20DB&hostname= every time you submit the form using the “Clear DB” button.

    Basically, to get the name of the button you pressed to submit the form, you just need to search for the button’s name. Another approach is using same name for buttons, but different values:

    <form id="mytestform" target="/cgi-bin/script.py" method="POST">
        <input type="submit" name="action" value="Clear"/>
        <input type="submit" name="action" value="Test"/>
    </form>
    

    Then you just need to check for the value of the request element you get (in the case above it would be “action”).

    In Python you would therefore just need to get the value you got via the FieldStorage class indeed, using FieldStorage.getfirst() method.

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

Sidebar

Ask A Question

Stats

  • Questions 486k
  • Answers 486k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer PHP Just time() will do what you want. If you… May 16, 2026 at 7:59 am
  • Editorial Team
    Editorial Team added an answer #pragma comment is a compiler directive which indicates Visual C++… May 16, 2026 at 7:59 am
  • Editorial Team
    Editorial Team added an answer Use OperationBindings: http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/data/DataSource.html#setOperationBindings%28com.smartgwt.client.data.OperationBinding...%29 You can control the url to contact,… May 16, 2026 at 7:59 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.