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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Collapse and Expand text fields on click of button

KKBDEL
Level 2
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

0 Replies
yodadobe
Level 6
Level 6

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.

Mandy_Wiesener
Level 5
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

yodadobe
Level 6
Level 6

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

Mandy_Wiesener
Level 5
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.

radzmar
Level 10
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

yodadobe
Level 6
Level 6

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.