I'm trying to get a numeric field to return a certain numeric value depending on the user's answer to a checkbox. Here's my code:
if (CheckBox1[0].rawValue == 1) then $.rawValue == 969.00 else $.rawValue == "" endif
When the form displays, the numeric field's value displays as $1.00 and if I check the box it changes to $0.00 - but I want it to return $969.00 when checked and be blank when not checked.
Can anyone help me figure this out?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
The syntax is FormCalc, so make sure you have set the language in the script editor to FormCalc.
Also, you are correct when testing equality to use the double equal sign ==. However when assigning a value you use a single equal sign.
FormCalc dosen't need the .rawValue.
Make sure that you have set the "specify values" in the checkbox Object/Binding tab and that on = 1. Also the [0] in your script indicates that there are more than one occurrence of CheckBox1. I would be inclined to name objects uniquely, as it makes it easier to script.
So this should work in the calculate event of the numeric field:
if (CheckBox1 == 1) then
$ = 969.00
else
$ = 0.00
endif
Set the pattern of the numeric field for the currency symbols, etc.
Good luck,
Niall
ps You might want to put the figues into quotation marks. Also having the script in the calculate event will automatically make the field calculated - read only. You may want this, but if you don't you can change it in the Object/Value tab. On the other hand you can have similar script in the exit event of the check box.
Views
Replies
Total Likes
Hi,
The syntax is FormCalc, so make sure you have set the language in the script editor to FormCalc.
Also, you are correct when testing equality to use the double equal sign ==. However when assigning a value you use a single equal sign.
FormCalc dosen't need the .rawValue.
Make sure that you have set the "specify values" in the checkbox Object/Binding tab and that on = 1. Also the [0] in your script indicates that there are more than one occurrence of CheckBox1. I would be inclined to name objects uniquely, as it makes it easier to script.
So this should work in the calculate event of the numeric field:
if (CheckBox1 == 1) then
$ = 969.00
else
$ = 0.00
endif
Set the pattern of the numeric field for the currency symbols, etc.
Good luck,
Niall
ps You might want to put the figues into quotation marks. Also having the script in the calculate event will automatically make the field calculated - read only. You may want this, but if you don't you can change it in the Object/Value tab. On the other hand you can have similar script in the exit event of the check box.
Views
Replies
Total Likes
Thanks so much - obviously I am just learning!
But I did have my language set correctly, it's only the == that caused the problem.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies