vendredi 8 septembre 2017

Dynamically Gridview that after click on button make list of all checked items (with checkbox)

I have a dynamic GridView of students that number of rows it depends on database information

example of my page/table

I want that after I press the button i will get a list of all checked PersonID in array/list.
I don't know how to write this JavaScript/jQuery function.

CheckBox:

<asp:CheckBox CssClass="chk" ID="Checkbox" runat="server" Text='<%# Bind("PersonID") %>'></asp:CheckBox>

Button:

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="myClosure1()" />

JavaScript:

<script type="text/javascript">

function myClosure1() {
    $('.chk').each(function () {
        var chkbox = $(this).children('input').get(0);
        if (chkbox.checked) {

        }
    });
}

</script>

I'm not sure it even gets inside the $('.chk').each

Aucun commentaire:

Enregistrer un commentaire