Get Multiple Checkbox Values Using jQuery | Code Snippet

17 Mar , 2013  Code Snippets 

Get-Multiple-Values-From-Checkbox-Using-jQueryCode Snippet #8: The code snippet we found for today can get multiple values from checkbox using jQuery. Get multiple values from checkboxes using jQuery dynamcally.

In one of our previous code snippet, we saw how to fetch multiple checkbox values with JavaScript. This time around, we are going to achieve the same thing using jQuery.

We know this this code won’t work without the jQuery framework inserted into the HTML document. This code can be really helpful in your upcoming or on going projects based on jQuery where you may need to get multiple checkbox values using jquery alone and the same may be needed to be passed to some other function or object.

Demo: [ Select one or more checkboxes below and hit the fetch values button ]

HTML:

jQuery:

Explanation:

The above code we have here is initiated on load of the window usign the below code snippet:

We store the values from the input checkboxes to the variable by name “valList” and add a comma after every value fetched. Once the input tag with button as the id is clicked, a alert box is generated, the function valList() is called where the values from the input are stored and only those checked are shown on the alert window using the statement:

Hope you liked this code. If you have any enhancements in mind, please let us know the same via comment.



, ,

  • ashis

    not working above script on click not diaplaying

  • prabhu

    great work. thanks