Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to check and uncheck all checkbox on single click?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 733
    Comment on it

    When we have multiple check box to select then we need to check all these one by one it will take more time to check all so by using jsscript we can check and unchecked all check box on a single click. In the below script can check and uncheck all check box on a click

    <form id="ItemBox">
        <table >
        <tr>
            <td>
                <input type="checkbox" name="checkAllCheckBox" id="checkAllCheckBox" onclick="checkedAll();">
            </td>
        </tr>
        <tr>
            <td>
            <input type="checkbox" name="book" id="book" value="Item 1">Item 1
            </td>
        </tr>
        <tr>
            <td>
            <input type="checkbox" name="book" id="book" value="Item 2">Item 2
            </td>
        </tr>
    
    
        <tr>
            <td>
            <input type="checkbox" name="book" id="book" value="Item 3">Item 3
            </td>
        </tr>
    
    
        <tr>
            <td>
            <input type="checkbox" name="book" id="book" value="Item 4">Item 4
            </td>
        </tr>
        </table>
        </form>
    
    checked = false;
         function checkedAll ()
            {
            if (checked == false)
                {
                checked = true
                }
            else
                {
                checked = false
                }
        for (var i = 0; i < document.getElementById("ItemBox").elements.length; i++)
            {
            document.getElementById("ItemBox").elements[i].checked = checked;
            }
          }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: