Select And Deselect All Checkboxes By Javascript

You can select and deselect all checkboxes by clicking two hyper
links(Select All and Deselect All).This type of functionality will be
needed some times in HTML table.

<!–if you have two hyperlinks like below–>
<A href=”javascript:checkUncheck(true);”>Select all</A>&nbsp;&nbsp;&nbsp;
<A href=”javascript:checkUncheck(false);”>Deselect all</A>
<!–then use this javascript to select all or to Deselect all–>

<script language=”javascript”>
    function checkUncheck(yes)
        for (i = 0; i < document.forms[0].elements.length; i++)
                document.forms[0].elements[i].checked = yes;

Leave a Reply

Your email address will not be published. Required fields are marked *