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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:16:17+00:00 2026-05-24T10:16:17+00:00

I have a form which have five buttons and several checkboxes holding different values.

  • 0

I have a form which have five buttons and several checkboxes holding different values.

<form action="" method="post" id="create-user">
    <button type="button" name="new-user">New</button>
    <button type="button" name="activate-user">Activate</button>
    <button type="button" name="block-user">Block</button>
    <button type="button" name="unblock-user">Unblock</button>
    <button type="button" name="delete-user">Delete</button>
    <input type="checkbox" value="1>" name="userId[]" />
    <input type="checkbox" value="2>" name="userId[]" />
    <input type="checkbox" value="3>" name="userId[]" />
    <input type="checkbox" value="4>" name="userId[]" />
    <input type="checkbox" value="5>" name="userId[]" />
</form>

now based on JavaScript event like onclick, i would like to perform different action for different buttons, for example.

a) <button type="button" name="new-user">New</button>

When User click this button it should redirect to following url.'index.php?users&option=create'.

b) <button type="button" name="activate-user">Activate</button>

this button is used for Ajax, it should fetch the selected checkbox value in an array i.e userId[], and send the data to manage-users.php and update form after receiving the response. and the rest three buttons Block, Unblock and Delete follows the same procedure as this.

And all this should be done using JQuery, as i am still a novice in JS/JQuery, i would appreicate if someone could guide me with creating JQuery function.

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-24T10:16:18+00:00Added an answer on May 24, 2026 at 10:16 am

    Easiest way is to add an id attribute to your buttons so you can easily target them with jQuery.

    For example:

    <form action="" method="post" id="create-user">
        <button type="button" name="new-user" id="new-user">New</button>
        <button type="button" name="activate-user" id="activate-user">Activate</button>
        <button type="button" name="block-user" id="block-user">Block</button>
        <button type="button" name="unblock-user" id="unblock-user">Unblock</button>
        <button type="button" name="delete-user" id="delete-user">Delete</button>
        <input type="checkbox" value="1>" name="userId[]" />
        <input type="checkbox" value="2>" name="userId[]" />
        <input type="checkbox" value="3>" name="userId[]" />
        <input type="checkbox" value="4>" name="userId[]" />
        <input type="checkbox" value="5>" name="userId[]" />
    </form>
    

    Then use jQuery to attach handlers for the click event on the buttons like so:

    <script type="text/javascript">
        $().ready(function(){
            $('#new-user').click(function() {
                // do your code here
            });
            $('#activate-user').click(function() {
                // do your code here
            });
            $('#block-user').click(function() {
                // do your code here
            });
            $('#unblock-user').click(function() {
                // do your code here
            });
            $('#delete-user').click(function() {
                // do your code here
            });
        });
    </script>
    

    That is not to say that you have to use ids to target the buttons you could use something like the following with your current HTML code:

    <script type="text/javascript">
        $().ready(function(){
            $('button[name="new-user"]').click(function() {
                // do your code here
            });
            $('button[name="activate-user"]').click(function() {
                // do your code here
            });
            $('button[name="block-user"]').click(function() {
                // do your code here
            });
            $('button[name="unblock-user"]').click(function() {
                // do your code here
            });
            $('button[name="delete-user"]').click(function() {
                // do your code here
            });
        });
    </script>
    

    ids are considered better practice though and are faster for the browser to locate in the DOM than search by attribute like in my last example.

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

Sidebar

Related Questions

I have a form which is given below : <form method=post id=contactForm action=> <fieldset
I have django form which displays the check boxes.After selecting the checkboxes user will
I have a form which contains several checkboxes align vertically in a div. I
I have a form which takes both the user details and an image uploaded
I have a form which I create manually (a lot of JavaScript in it...).
I have a form which users must fill out and submit. The controller action
I have form fields which are checkboxes as below : <input id=abirrules@gmail.com type=checkbox checked=checked
I have a form which contains a whole bunch of checkboxes and some other
I have grid view which contains five radio buttons per row. Out of these
I have an application containing a form with five input fields. When the user

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.