0

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

1 Answer 1

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

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

DEMO

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the response. Unfortunately i didnt get ids. Even though one of the checkbox is checked, test.length is not showing any value.
The jsfiddle demo did not load, but the code in the example worked fine for me in I.E.9. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.