I have a table with rows in, and each row has a few <td> elements. The last element has a checkbox in.
They are in a <div> which is set to runat="server". I have another checkbox on the page called “chkAll” that when clicked, I want to javascript check or uncheck all of the checkboxes in my table.
I’m not very good at Javascript, so I am not sure what to do. I added a javascript onclick method, and put document.getelementbyid and put in the div.clientID, but I wasnt sure what to do from there. Any ideas?
once you have the the
<div>element as a reference, usegetElementsByTagName()to get the<input>elements, then check thetypeproperty, if it’s a checkbox then set it’scheckedproperty the same as thecheckedproperty of the checkboxchkAll. For exampleand then attach this function as a click event handler of the
chkAllelementHere’s a Working Demo. add /edit to the URL to see the code