Skip to content
Advertisement

How to use same php function for different button clicks

Here is a simple PHP form with a button..

JavaScript

Here is the Jquery functions which executes a PHP file.

JavaScript

And the test.php is as follows,

JavaScript

My question is how to modify my test.php if I have multiple buttons.

As an example,

JavaScript

Result should be,

JavaScript

Update:

What If I need to run three different php functions(no any pattern)?

JavaScript

Advertisement

Answer

In here I am changing little bit your default settings. This will help you as I can understand. You can try as below,

1)Change your button into input type..I have added some inline CSS as well. If you don’t like you may neglect it…

JavaScript
  1. Then go to jquery and use as below, success function change as you wish. Here I have used an alert box…

    JavaScript
  2. Finally change your testme.php as follows,

    JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement