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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:46:19+00:00 2026-05-28T14:46:19+00:00

Frnds i want to submit data to two different controllers using two different buttons

  • 0

Frnds i want to submit data to two different controllers using two different buttons on one form and i want that both buttons call different actions and also provide all the values of the form to their respected controller.

  • 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-28T14:46:21+00:00Added an answer on May 28, 2026 at 2:46 pm

    You can do this with JavaScript like so:

    HTML

    <form method="POST" action="/">
        ... The Rest Of Your Form ...
        <input type="Submit" id="btn-1" name="btn-1" />
        <input type="Submit" id="btn-2" name="btn-2" />
    </form>
    

    JavaScript

    (function(d) {
        var form = d.getElementsByTagName('form')[0],
            targetBtn;
        form.onsubmit = function(e) {
            e.preventDefault();
            targetBtn = e.explicitOriginalTarget.id;
    
            //Set the form action based on the id of the button that submitted it
            if(targetBtn === 'btn-1') {
                form.action = '/foo';
            } else {
                form.action = '/bar'
            }
    
            //Submit your form
            form.submit();
        };
    }(document));
    

    All you need to do is make sure this code is placed after the from in the HTML markup or add it to a jQuery document.ready function.

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

Sidebar

Related Questions

hi frnds i want to set tab host on the bottom of screen using
I want to make an application (in .Net) that fills and submits a form
Hello frnds I have windows mobile application, that retrieves location info. Now i want
Hai Frnds, i want to know to launch a satellite application using Intent, i
I'm looking for a tool that finds duplicate nodes in a tree data structure
I want to build a query that finds elements that have the autofocus-attribute and
I want to create a PHP function that goes through a website's homepage, finds
I want to find a particular process using awk: ps aux|awk '/plugin-container.*Flash.*/' Now it
This is what I want. Submit a POST request to a external site(i.e login
I want something that finds instantly on the page a class called prop and

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.