code work in document JavaScript and not work in checkbox JavaScript
Hi expert...
I was developing new form of (Attendance Statement), I have 16 group of Check Boxes (in one page) , Every Group is about 20 Check boxes because it represent the Month without the Week ends!, The Problem is that code work very good inside (document JavaScript ) so i call the function from it to every checkbox, now i tried to delete the function from the Document java script because every page is 16 Trainer name, and if i add another page and i will do that, that mean that i have to write 32 function to be called from 32 group!, so i want everything to be simple if i could, also the (return) not work inside the button java script and it give me error (return only work in function), the main problem of the code that its warn me but it doesn't reset the check boxes,,, any help will be appreciated , thank you
// Initialize counter
// for First Trainer in First Page it will Start (A)
var CurrentField = "A"
var tarinee = getField("Trainer1");
var sum = 0;
var sum2 = getField("PeriodVar");
var sum3 = sum2.value;
// Loop through the check boxes
for (var i = 1; i <= 20; i++) {
// Increment counter if check box is selected
if (getField(CurrentField+i).value !== "Off") sum++;
// If more than sum3 are selected, deselect the one that was just selected,
// alert the user, and return
if (sum > sum3 ) {
event.target.value = "Off";
//Adding Asking if you want to delete all the marks
var scal = "The Max Number for Attendance is "
var scmsg = "Do you want to Remove Trainer marks? "
//check if the trainer name exist first
var tarineeName= tarinee.value;
if (app.alert(scal+sum3+"\n"+"\n"+scmsg+""+tarineeName, 2,2)==4)
for (var i=1;i<=20;i++)
{
this.resetForm(CurrentField+i);
}
//return;
}
}
