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

  • Home
  • SEARCH
  • 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 3434094
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:39:22+00:00 2026-05-18T07:39:22+00:00

I have a few <div> inside a forms, each thing inside the div contains

  • 0

I have a few <div> inside a forms, each thing inside the div contains a specific form.
When a user presses the submit button, I want to execute a different action based on

<form method="get" action="addprogramtodb.jsp">
<select name="cid"  style="display: none;">
<option>1</option>
<option>2</option>
</select>

<div id="1">
</div>

<div id="2">
</div>

<div id="3">
</div>

<input type="submit"/>
</form>

When the user presses the submit button I want the program to execute different queries based on what div it is in…. based on the div id, or somehow..

  • 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-18T07:39:22+00:00Added an answer on May 18, 2026 at 7:39 am

    Give the submit button a name and value the usual way.

    <input type="submit" name="action" value="action1">
    ...
    <input type="submit" name="action" value="action2">
    ...
    <input type="submit" name="action" value="action3">
    

    The pressed button is namely available as request parameter as well.

    String action = request.getParameter("action");
    
    if ("action1".equals(action)) {
        // action1 button is pressed.
    } else ("action2".equals(action)) {
        // action2 button is pressed.
    } else ("action3".equals(action)) {
        // action3 button is pressed.
    }
    

    You can if necessary give them a different name instead and then nullcheck each request parameter.

    <input type="submit" name="action1" value="This is more i18n friendly">
    ...
    <input type="submit" name="action2" value="Blah">
    ...
    <input type="submit" name="action3" value="More blah">
    

    with

    if (request.getParameter("action1") != null) {
        // action1 button is pressed.
    } else (request.getParameter("action2") != null) {
        // action2 button is pressed.
    } else (request.getParameter("action3") != null) {
        // action3 button is pressed.
    }
    

    Or, if they are actually all in their own <form>, then you can also pass a hidden input along.

    <form> 
        <input type="hidden" name="action" value="action1">
        ...
    </form>
    <form> 
        <input type="hidden" name="action" value="action2">
        ...
    </form>
    <form> 
        <input type="hidden" name="action" value="action3">
        ...
    </form>
    

    with the same server-side handling as in 1st example.

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

Sidebar

Related Questions

I have a div called divContainer inside which i have few input elements like
I have a form with a few input fields. When a user clicks on
I have a few divs inside a div. <div class=outside> <div class=inside></div> <div class=inside></div>
I have a couple of div tags nested within each other and a few
I have few nested DIV elements. For example: <div id='id1'><div id='id2'>content</div></div> I attach event
Ok, so i have a few <div1> elements with static content inside of them.
I have few div HTML elements and i am cloning it with a clone(true)
I have a login.jsp page which contains a login form. Once logged in the
I have few asynchronous tasks running and I need to wait until at least
I have few different applications among which I'd like to share a C# enum.

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.