Skip to content
Advertisement

how to get multiple checkbox values from html form

I understand that I can use jQuery (how to get multiple checkbox value using jquery) to get checkbox values when there are multiple, but my checkbox inputs are inside an html form, so those jQuery solutions aren’t working because none of them get the checkbox values from within a form.

I try to extract the values from the form, but it just creates a weird radio nodelist that seems to count the number of times the name of the checkboxes appears in the doc rather than the values.

JavaScript
JavaScript

But I have no idea how to get the js to get the value of whats inside the form inputs instead of counting something else, and no idea how to access the values of the checked boxes

Advertisement

Answer

You can use jQuery .map() function to iterate through each checked checkbox input type. This will return an object with the selected checkboxes. Now, to get an array from the jQuery object we can use the .get() method like this:

Try this:

JavaScript
JavaScript
Advertisement