Kris-I Kris-I - 1 year ago 114
Javascript Question

Get checkbox list values with jQuery

In a div, I have some checkbox. I'd like when I push a button get all the name of all check box checked. Could you tell me how to do this ?

<div id="MyDiv">
<td><%= Html.CheckBox("need_" + item.Id.ToString())%></td>


Answer Source
$(document).ready(function() {
    $('#someButton').click(function() {
        var names = [];
        $('#MyDiv input:checked').each(function() {
        // now names contains all of the names of checked checkboxes
        // do something with it
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download