Check/uncheck checkboxes in TreeView using javascript
Hi,
In my ASP.NET page I have a TreeView where ShowCheckBoxes="Leaf".
I want to mark as checked/unchecked all the visible checkboxes by clicking in a button.
My code for selecting all/none nodes is like this:
function selectAllNone(tvID, value) {
var tvNodes = document.getElementById(tvID);
var chBoxes = tvNodes.getElementByTagName("input");
for (var i = 0; i < chBoxes.length; i++) {
var chk = chkBox[i];
if (chk.type == "checkbox") {
chk.cheked = value;
}
}
}
However, in the line var chBoxes =tvNodes.getElementByTagName("input");I'm having this error message: object doesn't support this property or method.
How do I checj/uncheck all the checkboxes, then?
in the beginning of each post there is a "add to serkan's reputation" link , you basically click on it and then select agree radio button then type something then click ok.
Looks simple.
Change
var tvNodes = document.getElementById(tvID);
to
var tvNodes = document.getElementsById(tvID);
Hope It worked.Do tell Us.
Happy Coding.
Hi,
In my ASP.NET page I have a TreeView where ShowCheckBoxes="Leaf".
I want to mark as checked/unchecked all the visible checkboxes by clicking in a button.
My code for selecting all/none nodes is like this:
function selectAllNone(tvID, value) {
var tvNodes = document.getElementById(tvID);
var chBoxes = tvNodes.getElementByTagName("input");
for (var i = 0; i < chBoxes.length; i++) {
var chk = chkBox[i];
if (chk.type == "checkbox") {
chk.cheked = value;
}
}
}
However, in the line var chBoxes =tvNodes.getElementByTagName("input");I'm having this error message: object doesn't support this property or method.
How do I checj/uncheck all the checkboxes, then?
Just use the below code. The first one have lot of spelling mistakes.
function selectAllNone(value) {
var tvNodes = document.getElementById("trvMenu");
var chBoxes = tvNodes.getElementsByTagName("input");
for (var i = 0; i < chBoxes.length; i++) {
var chk = chBoxes[i];
if (chk.type == "checkbox") {
chk.checked = value;
}
}
return false;
}