elamaran
elamaran

Reputation: 73

Jquery get list of checkbox ids to send to mvc controller action

I have multiple form with unique id and has same set of checkbox elements. I want to get the list of checkbox ids in an array using jQuery and send it to mvc action where the argument is of type IEnumberable.

I used the below code in jQuery to get the checked checkbox inside the form but not successful. Can anyone help me how to solve this?

        var test = $("#11form input[type='checkbox']:checked");
        alert(test.length);  

Thanks in advance

Upvotes: 0

Views: 1038

Answers (1)

thecodeparadox
thecodeparadox

Reputation: 87073

var test = $("#11form input[type='checkbox']:checked");

var ids = test.map(function() {
  return this.id;
}).toArray();

DEMO

Upvotes: 1

Related Questions