Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

Counting Checkboxes with different Names

Not applicable
I have a form that I am creating in Livecycle Designer 8.0 that has 100 checkboxes that the user selects from. I would like to have a field that counts how many check boxes are checked. What is the easiest way to do this?



Also, Do I have to add each field individually or is there a way to select them all and insert to the formula at once?



Thanks!
3 Replies
pguerett
Level 10
Level 10
You can write a script that will query the number of objects in the form. Once you have that you can get each object one by one and see which type of object it is. If it is a checkbox you can see if it is checked or not. If checked then you can add it to your counter. If you send me your form I will incorporate it into a button event for you to see.
Not applicable
send me the form,will get it working for you

mergeandfuse@gmail.com
Not applicable
Big thanks out to Paul Guerette for helping me write the script for this. He gave me an option to do it as an exit event of the pages or on a button click. Here is the code for the button click:



- form1.Order_Page.Button1::click: - (JavaScript, client) ---



form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue = 0;



//app.alert("Page1 Exit Event fired!!!!");

//Get total number of element on Page 1 of the form

var allChildElements = form1.Course_Selection_Subform1.Course_Selection_Page_1.nodes;

var intNumElements = allChildElements.length;



//app.alert("The number of elements is: " + intNumElements);



//Loop through all the objects on Page1

for(j=0; j< intNumElements;j++){

//set the 1st object to a variable name

currentElement = allChildElements.item(j);



//if the object is a field then test to see if it is a checkbox

if(currentElement.className == "field") {

//app.alert(currentElement.ui.oneOfChild.className);

// is it a checkbox?

if (currentElement.ui.oneOfChild.className == "checkButton"){

//Is the checkbox checked?

if (currentElement.rawValue == "1"){

//increment the Course_Quantity field

form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue = form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue + 1;

}

}

}



}



//app.alert("Page2 Exit Event fired!!!!");

//Get total number of element on Page 1 of the form

var allChildElements = form1.Course_Selection_Subform2.Course_Selection_Page_2.nodes;

var intNumElements = allChildElements.length;



//app.alert("The number of elements is: " + intNumElements);



//Loop through all the objects on Page1

for(j=0; j< intNumElements;j++){

//set the 1st object to a variable name

currentElement = allChildElements.item(j);



//if the object is a field then test to see if it is a checkbox

if(currentElement.className == "field") {

//app.alert(currentElement.ui.oneOfChild.className);

// is it a checkbox?

if (currentElement.ui.oneOfChild.className == "checkButton"){

//Is the checkbox checked?

if (currentElement.rawValue == "1"){

//increment the Course_Quantity field

form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue = form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue + 1;

}

}

}

}