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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:09:18+00:00 2026-05-16T01:09:18+00:00

For example, I have a HTML form with several input buttons, <form action=/index.php method=post>

  • 0

For example, I have a HTML form with several input buttons,

 <form action="/index.php" method="post">
 <input type="hidden" name="hf" />
 <input type="submit" id="apply_action" name="action" value="Apply">
 <input type="submit" id="cancel_action" name="action" value="Cancel">

it’s the current framework of a large web project. Once Submit button ‘Apply’ is clicked, it will map to a particular PHP function on the web server, and then return certain HTML code back; of course, once ‘Cancel’ is clicked, it will map to another PHP function.

Now, I would like to add some stuff before the original submit action when the ‘Apply’ is clicked. For example: I would like to add an javascript alert (“hello”) before the original submit action is sent to the server? I dont know how to achieve this with Jquery? First of all, there are two submit actions for this form, value=’Apply’ or ‘Cancel’, I need to differentiate the action;
Second, after alert(‘hello’), I still need the original form action=’index.php’ to be executed.
Is there a jquery function for this purpose? 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-16T01:09:19+00:00Added an answer on May 16, 2026 at 1:09 am

    It sounds like you wish to bind a function to the form’s submit event. See http://api.jquery.com/submit/

    To fit your request, this should work:

    $('form').submit(function(){
      alert('hello');
      return true;
      });
    

    Addendum:

    Okay, since you have two submit buttons, you’ll need to use the click event.

    $(document).ready(function(){
      $('input').click(function(ev){
       alert(ev.target.id);//this is how you will differentiate between the two buttons.
          //or, you could bind a separate click event to each one
       if(ev.target.id=="cancel_action"){ /* etc.. */ }
       else{ /* etc.. */ }
       });
     });
    

    With either method, the form will be submitted on click. As noted by Francisco Soto, returning false will prevent the submission from either method. Returning true (or not specifying a return value) will continue with the form submission.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The way this typically works is that the UI is… May 16, 2026 at 11:44 am
  • Editorial Team
    Editorial Team added an answer For both analyzers, the first line should be the tokenizer.… May 16, 2026 at 11:44 am
  • Editorial Team
    Editorial Team added an answer Pretty certain this isn't possible without resorting to COM interop… May 16, 2026 at 11:44 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

Related Questions

I have an HTML table with several columns and I need to implement a
I have normal HTML input fields, that have default borders depending on Window/Browser settings.
I know that XHTML doesn't support nested form tags and I have already read
Since switching to Windows 7, we've noticed that several of our web pages have
Currently my AJAX is working like this: index.php <a href='one.php' class='ajax'>One</a> <div id=workspace>workspace</div> one.php
I am not strong on my PHP knowledge, but I have never seen this
Can anyone help with this strange form submiting in FireFox? So this form should
I was trying to understand how ajax works with django several times, but looks
Using PDF, is it possible to create a single form element with multiple fields
I'm trying to achieve the following behaviour in html: user is presented with a

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.