RealBeginner
10-07-2002, 11:26 AM
Hi All,
I am trying to write a function that will indicate to me whether or not the checkboxes on my web page are checked or not.
I am using a database and the number of checkboxes can vary depending on what dates the user selected. I have a button that has an onClick event to run the tester function. The checkboxes are called "chbPlanned<%number%>".
I want to go through the form elements that's name starts with "chbPlanned" and that are checked and then have a pop-up with the element name and whether or not it is checked.
Below is the function I have written but I keep getting problems. Can someone help me please.
function tester()
{
temp = document.formName.elements.length ;
for (i=0; i<temp; i++) {
if ((leftcontext(document.formName.elements[i].name,10) == "chbPlanned")) && ((document.formName.elements[i].checked == 1) {window.alert(document.formName.elements[i].name +" is"))}
else {window.alert(document.formName.elements[i].name +" not")}
}
}
Thanks in advance.
I am trying to write a function that will indicate to me whether or not the checkboxes on my web page are checked or not.
I am using a database and the number of checkboxes can vary depending on what dates the user selected. I have a button that has an onClick event to run the tester function. The checkboxes are called "chbPlanned<%number%>".
I want to go through the form elements that's name starts with "chbPlanned" and that are checked and then have a pop-up with the element name and whether or not it is checked.
Below is the function I have written but I keep getting problems. Can someone help me please.
function tester()
{
temp = document.formName.elements.length ;
for (i=0; i<temp; i++) {
if ((leftcontext(document.formName.elements[i].name,10) == "chbPlanned")) && ((document.formName.elements[i].checked == 1) {window.alert(document.formName.elements[i].name +" is"))}
else {window.alert(document.formName.elements[i].name +" not")}
}
}
Thanks in advance.