Copy link to clipboard
Copied
Hi All,
Please forgive my ignorance in Java - I am attempting to create a calculated field which has a base value, then if a tickbox is checked, add X to the base rate (this needs to work for multiple checkboxes); what I have so far:
event.value = 0.07;
if(checkBox1.rawValue==true)
{event.value+0.015}
if(checkBox2.rawValue==true)
{event.value+0.05}
this needs to be additive so if (for example) tickbox 1,4,6 and 8 are ticked, all their denoted values will be added to the base rate.
Example:
tickbox 1 = 0.015
tickbox 4 = 0.05
tickbox 6 = 0.02
tickbox 8 = 0.01
textbox = 0.07+0.015+0.05+0.02+0.01
any help would be greatly appreciated!
Regards
Sure, it can be done, but your code was written for an LCD form, which is why we wanted to make sure what kind of form you have.
You can use something like this as the custom calculation script of the field where you want to show the total value:
var v = 1.24; // base value
if (this.getField("tickbox 1").valueAsString!="Off") v+=0.015;
if (this.getField("tickbox 4").valueAsString!="Off") v+=0.05;
// etc.
event.value = v;
Copy link to clipboard
Copied
This question would be best in the LiveCycle Designer forum, so I'll move it there for you: LiveCycle Designer
Copy link to clipboard
Copied
I am not using LiveCycle Designer - are you saying that it cannot be done with normal Adobe X Pro calculated form field?
Copy link to clipboard
Copied
Sure, it can be done, but your code was written for an LCD form, which is why we wanted to make sure what kind of form you have.
You can use something like this as the custom calculation script of the field where you want to show the total value:
var v = 1.24; // base value
if (this.getField("tickbox 1").valueAsString!="Off") v+=0.015;
if (this.getField("tickbox 4").valueAsString!="Off") v+=0.05;
// etc.
event.value = v;
Copy link to clipboard
Copied
Awesome, works like a bomb! thanks Try67!
Copy link to clipboard
Copied
So my joy was short-lived due to the form needing to be filled out in the field - meaning that for most users, JavaScript custom calcs are disabled for iPads et al. is there any way to write this as a basic math equation using the simplified notation?
Copy link to clipboard
Copied
All of the calculation options rely on JavaScript, you just don't see it with the first two options. So if the PDF viewer doesn't have sufficient support for JavaScript, there's nothing you can do.
Copy link to clipboard
Copied
The simplified field notations to calculate other fields with math formulas work fine, it is just the custom script done above that doesn't work.
Copy link to clipboard
Copied
You can try this: Apply the value associated with each check-box as its export value and then use the Simple Field Notation option to simply add up all of those fields, plus the base value (which you can hard-code into the formula as a number or place into a hidden field and then add that field to the sum).
Copy link to clipboard
Copied
Try67 with the win once again! nicely done. thanks very much for your help!
Copy link to clipboard
Copied
If you're creating the form in Acrobat instead, let me know and I'll move it back to the Acrobat JavaScript forum.