Click here to Skip to main content
15,796,025 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I created such a table as its rows 1st element is a checkbox.
I created another control (checkbox) and want to click on to change all of checkboxes in the table using the function below.
The values of checkboxes in the table get changed. However, how can I refresh the table on the HTML page? Should I make a ajax call, and how? Thanks.

function checkAll(v, chk) {
    var b = chk.checked;
    for (var i = 0; i < v.length; i++) {
        var vCells = v[i].cells;
        var _chk = _cells[0].getElementsByTagName("input")[0];
        var _id = _cells[1].innerHTML;

    function onoff (chk_) {
        if (chk_.checked) chk_.checked = false;
        else chk_.checked = true;

What I have tried:

How to refresh the controls?
Updated 7-Jun-21 4:31am

1 solution

It's a bit difficult to determine what you are looking for.
Try putting sample code at a place you can share it and show what you're looking for.

I've guessed at what you're looking for and created a nice jsbin that you can run to see. Try this : JS Bin - Collaborative JavaScript Debugging[^]

That will select all of the checkboxes and select none of them.
You can probably work out what you want from there.
Share this answer
s yu 7-Jun-21 10:34am    
Thanks a lot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900