Each row of a ListView has a checkbox. When the user clicks Delete Selected row(s) LinkButton, only rows that have the checkbox checked are deleted. I’m thinking about getting all the checkboxes in an array first then loop through to see which one was checked.
This is what I have tried.
function CheckBoxBeforeDeleteing() {
var lv = document.getElementById("MainContent_ListView1");
//var inputs = lv.childNodes;
//alert(inputs.Length);
alert("Test");
}
If I don’t comment out the 2 lines, the function is not even executed. It looks like I need to go deeper. Does Javascript has something function like the C#’s FindControlRecursive?
You can loop through the elements in the forms using loop in javascript as give below. Suppose you have
form1in your page withrunat="server"then get the form and iterate through its controls using loop and find the checkboxes within form.Accessing form with index