Copy link to clipboard
Copied
I would like to have a check box field and if selected it would return a value in another field. Eg. if selected take the value in field "subtotal" and multiply it by 0.05. return that value in field "GST". Is this possible.
Copy link to clipboard
Copied
Yes, but it's better to do it from the calculation event of the target field ("GST") then from the check-box itself.
What should be the value of this field if the box is not ticked, though?
Copy link to clipboard
Copied
The value would be $0.00
Copy link to clipboard
Copied
OK, then use this code as the custom calculation script (you'll just need to adjust the names of the fields involved to match the actual names in your file):
var subtotal = Number(this.getField("subtotal").value);
event.value = (this.getField("CheckBox1").value=="Off") ? 0 : subtotal * 0.05;
Copy link to clipboard
Copied
Sorry, I am not very familiar with code. Am I pasting the code into the custom calculation script of the GST field? I did and the field names you used are exactly what mine are titled (GST, Subtotal and CheckBox1) but when I check CheckBox1 nothing happens and the GST field does not return a value.
Copy link to clipboard
Copied
Yes, that's basically it, but be aware that JS is case-sensitive. So if the field is called "Subtotal" and in the code you have "subtotal" it won't work. You should also check the JS Console (Ctrl+J) for any error messages.