Expand my Community achievements bar.

SOLVED

SubForm's Loop and hiding based on checkbox

Avatar

Former Community Member

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

Avatar

Correct answer by
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

Avatar

Correct answer by
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!

Avatar

Former Community Member

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