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

SOLVED

SubForm's Loop and hiding based on checkbox

jasons17295687
Level 1
Level 1

I have a form where sub forms have a check box in them.  I need a script when the user clicks a button to hide all sub forms that don't have the check box checked.  Thanks for any assistance you can provide.

var allChildElements;

var intNumElements;

var currentElement;

var i;

allChildElements = CRT130.nodes;

intNumElements = allChildElements.length;

for (i=0; i<intNumElements; i++)

{

currentElement = allChildElements.item(i);

if(currentElement.className === "checkbox")

{

  if(currentElement.rawValue == 0)

  {

  currentElement.presence = "hidden";

  }

}

}

Heirarchy.png

1 Accepted Solution
Magus069
Correct answer by
Level 10
Level 10

Hi there,

the className of a checkbox is "field", if you want to verify if the item is a checkbox, you have to access to the ui's field to be able to verify what kind of field it is.

Although for a checkbox the className is checkButton instead of checkbox.

You would need to create a recursive function to loop through each subform and also each items within the subform.

Create a script object (xfaCheckBoxes) with the function above within, and then you can call the function on the button's click event

This should do the trick,

I hope it will help!

View solution in original post

2 Replies
Magus069
Correct answer by
Level 10
Level 10

Hi there,

the className of a checkbox is "field", if you want to verify if the item is a checkbox, you have to access to the ui's field to be able to verify what kind of field it is.

Although for a checkbox the className is checkButton instead of checkbox.

You would need to create a recursive function to loop through each subform and also each items within the subform.

Create a script object (xfaCheckBoxes) with the function above within, and then you can call the function on the button's click event

This should do the trick,

I hope it will help!

View solution in original post

jasons17295687
Level 1
Level 1

Works great thank you very much!  I had been going around and around with this one.