Tuesday, 15 October 2013

Check all checkboxes


<input id="chkall" type="checkbox" title="Select/Clear All" onchange="getselect(this)"/>
for (int i = 0; i < Model.lst.Count; i++)
{
@Html.CheckBoxFor(m => m.lst[i].Aid, new { @class="chk", id="chk" })
}

<script type="text/javascript">
   
    function getselect() {
        if (document.getElementById('chkall').checked) {
            $('.chk').prop('checked', true);
        }
        else {
         
            $('.chk').prop('checked', false);
           
        }    
    }
        

</script>

No comments:

Post a Comment