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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:37:39+00:00 2026-05-19T02:37:39+00:00

I have one form that has several elements and two submit buttons, one is

  • 0

I have one form that has several elements and two submit buttons, one is “Save” the other is “Delete”. On the “Delete” button I am using jQuery dialog to confirm user wants to delete. Then if they confirm, I submit the form. The problem is jQuery.submit() doesn’t include the original submit button when it is posted so I can’t distinguish on the server a Delete from a Save since they are both using the same form. If I remove the jQuery dialog then the submit button value is posted as expected. This HAS to be very common and I am hoping someone can share a solution. I’ve searched around and can’t find anything useful (is it just me or is google sucking lately?)

Thanks for any help…

EDIT:

The submit buttons do have names and values set. It works fine if don’t use jQuery.submit()

  • 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-19T02:37:39+00:00Added an answer on May 19, 2026 at 2:37 am

    Based on karim79’s answer:

    $("input[type=submit], input[type=button], button").click(function(e) {
        var self= $(this),
            form = self.closest(form),
            tempElement = $("<input type='hidden'/>");
    
        // clone the important parts of the button used to submit the form.
        tempElement
            .attr("name", this.name)
            .val(self.val())
            .appendTo(form);
    
        // boom shakalaka!
        form.submit();
    
        // we don't want our temp element cluttering up the DOM, do we?
        tempElement.remove();
    
        // prevent default since we are already submitting the button's form.
        e.preventDefault();
    });
    

    UPDATE:

    I just realized the above code is probably not what you are looking for:

    If you are calling submit on the form element itself ($("form").submit();) you will need something like this:

    $("form").submit(function(){
        var form = $(this);
        $("input[type=submit], input[type=button], button", form).eq(0).each(function(){
            var self= $(this),
                tempElement = $("<input type='hidden'/>");
    
            // clone the important parts of the button used to submit the form.
            tempElement
                .attr("name", this.name)
                .val(self.val())
                .appendTo(form);
        });
    });
    

    Which will add the first button element’s name and value to the DOM right before the form is submitted (I’m not sure what the default browser behavior is here). Note that this doesn’t remove the tempElement from the DOM. If there is an error and the form isn’t submitted the element will remain and you will have problems if you don’t take care of this.

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

Sidebar

Related Questions

I have 3 buttons in a form. One of them is the submit button.
I have a form element and that has a normal submit button but I
I have a Model that has several properties. When I submit a form, I
Using web forms I know that you can only have one ASP.NET form on
My form has several <p> elements which are added dynamically. This is how one
IDE: Microsoft Visual Studio Professional 2008 Language: C# Background: I have one form and
I'm working on a C# program, and right now I have one Form and
I have an application with one form in it, and on the Load method
When submitting one form from view, how can i also read or have controller
I have a form with thousands of checkboxes, and when one is checked, I

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.