Expand my Community achievements bar.

SOLVED

How do you make columns invisible/visible or hidden with checkbox?

Avatar

Level 2

Hi , i'm trying to make a column in a table either visible or invisible when i click a checkbox or button.

i have a single row table with mutiple columns of text objects within, i have set the "repeat data for each row item" to min 4, so i have four diplayed on page.

i have set the checkbox with the following script but it only makes the first row of "Received" visible when i click on the checkbox. and not the other

3 "Received" textobjects.

example:

form1.purchaseOrder.ProductHeader.Receivedchkbox::click - (JavaScript, client)

if (this.rawValue == "1") {       
    form1.purchaseOrder.Productdetails.detail.received.presence = "visible";
    form1.purchaseOrder.Productdetails.detailHeader.StaticReceived.presence = "visible";
}
else
{
    form1.purchaseOrder.Productdetails.detail.received.presence = "invisible";
    form1.purchaseOrder.Productdetails.detailHeader.StaticReceived.presence = "invisible"


}

So what i'm trying to acheive is for the form to make the "Received" textobject "invisible or hidden" at default.

Then when the form filler clicks the checkbox it become visible and vice versa.

So How do i apply a script like this to hide all 4 "Received" instances and  also the new ones i add by addinstance script?

I have attached the form, if someone could give me some help in working it out?

Thanks!!!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

It does help to see the form!

Basically you need to loop through all of the instances of the detail row and change the presence of the received object individually.

First the script would calculate the number of rows:

var vRows = Productdetails._detail.count;

The use of _ before the repeating detail is shorthand for instanceManager.

Then the if statement would change slightly, with the insertion of a for statement which works through all four rows.

if (Receivedchkbox.rawValue == true) {     

     form1.purchaseOrder.Productdetails.detailHeader.StaticReceived.presence = "visible";

     for(var i=0; i<vRows; i++) {

          xfa.resolveNode("form1.purchaseOrder.Productdetails.detail[" + i + "]").receivedSubform.presence = "visible";

     }

}

else ...
Form attached.
Good luck,
Niall

View solution in original post

3 Replies

Avatar

Level 2

Ive added the form for someone to look at see what i'm doing is right.

I'm new to LC and this is my first form.


Any help is greatly appreciated. Thanks

Avatar

Correct answer by
Level 10

Hi,

It does help to see the form!

Basically you need to loop through all of the instances of the detail row and change the presence of the received object individually.

First the script would calculate the number of rows:

var vRows = Productdetails._detail.count;

The use of _ before the repeating detail is shorthand for instanceManager.

Then the if statement would change slightly, with the insertion of a for statement which works through all four rows.

if (Receivedchkbox.rawValue == true) {     

     form1.purchaseOrder.Productdetails.detailHeader.StaticReceived.presence = "visible";

     for(var i=0; i<vRows; i++) {

          xfa.resolveNode("form1.purchaseOrder.Productdetails.detail[" + i + "]").receivedSubform.presence = "visible";

     }

}

else ...
Form attached.
Good luck,
Niall

Avatar

Level 2

thankyou Niall, works great !!!!!!