Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

How do I code conditional text?

Avatar

Level 1

I have a form that needs to display Text Block 1 only if the "Total" is up to $499.99." If $500 or greater, I need to hide Text Block 1 and show Text Block 2.

Is there any way I can do this?

Thanks.

2 Replies

Avatar

Level 10

Assuming your text blocks are different text objects and total is a numerice field, you can use a script in the total field calculate event.

FormCalc:


if ($ lt 500) then


    textBlock1.presence = "visible"


    textBlock2.presence = "hidden"


else


    textBlock1.presence = "hidden"


    textBlock2.presence = "visible"


endif


JavaScript:



textBlock1.presence = this.rawValue < 500 ? "visible" : "hidden";


textBlock2.presence = this.rawValue < 500 ? "hidden" : "visible



";


Avatar

Level 1

Beautiful!  That is just what I needed.

Thanks so much for taking the time to respond.

Katy