Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Collapse and Expand text fields on click of button

Avatar

Level 2

Hi,

I have a form with several multiline text fields taking almost 2-3 pages..i do not need them always ..is there a way where i can have a kind of "OPEN" and "CLOSE" type of functionality to expand and collapse these text fields.

Thanks

Kapil

6 Replies

Avatar

Former Community Member

JavaScript in a button click or maybe a check box:

TextField1.presence = "hidden";

TextField1.presence = "visible";

The sub form the items are in and all above it in the tree must have autosize on height.

Avatar

Level 5

The best way is really the solution from Steve.

Important is that the subform content is flowed!! Then the system activate automatically the height autosize. And then the the hidden field don't need place.

In the field or checkbox which you decided if you need or not need the dynamic field you could use the following code in the CLICK oder CHANGE-Event:

//means the checkbox is activated

if(checkbox.rawValue ==1)

{

     TextField1.presence = "visible";

}else

//means the checkbox is deactivated

{

     TextField1.presence = "hidden";

     // I would prefer to reset the hidden field

     TextField1.rawValue = "null";

}

Please inform us when you want to use these fields, then we can make help with the condition.

You have the possibillity to change the field-height with: TextField.h = "0pt"; But I think this is not the best way for your problem.

Hopefully helpfull,

Mandy

Avatar

Former Community Member

You need to use xfa.event.newText in the calculate event. rawValue will give the old value.

Avatar

Level 5

@Steve:

I worked often with rawValue and have no problems with them. It always work correct.

Only by dropdown I use xfa.event.newText in the change-event with the switch statement.

Avatar

Level 10

Here is a sample form with a collapsing text field.

With a button you can expand/collaps the field as you need.

https://workspaces.acrobat.com/?d=uluWF9NaAmvOe45rYXQmEQ

Avatar

Former Community Member

I meant to say change event per what your example was. I guess it is an intersting bit of info that rawValue will work in the change event of a checkbox. I'll stick to using xfa.event.newText to be consistent and ensure someone looking at my code to apply to something else doesn't have a problem.