Skip to main content
Brendon87
Known Participant
August 27, 2018
Answered

Base rate plus tick box

  • August 27, 2018
  • 2 replies
  • 1019 views

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

This topic has been closed for replies.
Correct answer try67

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;

2 replies

Inspiring
August 27, 2018

If you're creating the form in Acrobat instead, let me know and I'll move it back to the Acrobat JavaScript forum.

Inspiring
August 27, 2018

This question would be best in the LiveCycle Designer forum, so I'll move it there for you: LiveCycle Designer

Brendon87
Brendon87Author
Known Participant
August 27, 2018

I am not using LiveCycle Designer - are you saying that it cannot be done with normal Adobe X Pro calculated form field?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 27, 2018

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;