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.

a if statement and output error

Avatar

Level 1

In my form (XML dynamic) I would like to output an error message if the total of a addition is either $200.00 or $250.00.

The name for the calculated amount is called "TOTAL" as outlined in my code below.

My code:

if ( "TOTAL" = 200.00 ) then
I want to output an error message in a box called "ERRORbox"

elseif ( "TOTAL" = 250.00 ) then

I want to output an error message (same message as above) in a box called "ERRORbox"

100
endif

Thanks

2 Replies

Avatar

Level 6

We need to go little bit in to basics........

1.When you used "" around TOTAL it is considered as Static text (in other words string constant) So if you remove those "" that will be considered as variable and in runtime the value of that variable is replaced for execution.

2. In FormCalc the equal operator is represented as == not with single =

So try the following hopefully that will work..........

if ( TOTAL == 200.00 ) then
I want to output an error message in a box called "ERRORbox"

elseif ( TOTAL == 250.00 ) then

I want to output an error message (same message as above) in a box called "ERRORbox"
endif

if that did not work try the following.....some times FormCalc is picky and do string comparisons even though it suppose to do numeric comparison.

if ( TOTAL == "200.00" ) then
I want to output an error message in a box called "ERRORbox"

elseif ( TOTAL == "250.00" ) then

I want to output an error message (same message as above) in a box called "ERRORbox"
endif

Let me know if you still have issues.

Avatar

Level 1

Thanks so much for the help.

What I did is select the ERRORbox and then using FormCalc i tried both your coding examples. I receive an error when I open the PDF but when I insert your code in the Javascript window I do not receive an error in the PDF but still not working.

I have attached the file hopefully you will be able to view it. The values 200.00 and 250.00 are obtained from #1. REGISTRATION Options - in the radio buttons. My idea if the person accidedily selects one of the options in #1 it will display an error message in the white box where the word "Check" is - this way for only the one days registration the cost is $40.00 - Really hope I am clear in my explanation.