Copy link to clipboard
Copied
I have a form with a tick box that adds a value to a single field when ticked, and zeroes it when unticked.
The custom calculation script in this single field is:
event.value = this.getField("Tick domestic electrical").value == "Off" ? 0 : 516;
This works OK.
However I want a second tick box that adds the same value to that single field as well.
But I want it to add that same value, only if the other box is unticked and vice versa.
How can I get this to work?
Copy link to clipboard
Copied
if(this.getField("Tick domestic electrical").value == "Off" &&
this.getField("Tick domestic electrical2").value == "Off")
{event.value=0}else{event.value=516}
Copy link to clipboard
Copied
You can use something like this:
var v1 = this.getField("Tick domestic electrical").value == "Off" ? 0 : 516;
var v2 = this.getField("Tick domestic electrical2").value == "Off" ? 0 : 516;
event.value = v1+v2;
Copy link to clipboard
Copied
Thanks, I removed the previous script and added this one, now the field stays at zero when I click or unclick the tick box.
Copy link to clipboard
Copied
Did you make sure to enter the correct field name in the second line of code? I just added "2" at the end of the one you used, since you didn't specify what it should be in your original post.
Copy link to clipboard
Copied
Yes you're right sorry it's case sensitive.
The fields are now inputting, but when I tick the second box it adds the first tick box value to the second.
I don't want that, it only needs to add one instance of the value.
If the second box is ticked also it doesn't add a further value to the field.
Copy link to clipboard
Copied
if(this.getField("Tick domestic electrical").value == "Off" &&
this.getField("Tick domestic electrical2").value == "Off")
{event.value=0}else{event.value=516}
Copy link to clipboard
Copied
That's absolutely perfect thanks very much for your help.
Copy link to clipboard
Copied
Sorry, I misunderstood what you meant. The code you got from @PDF Automation Station should do the trick.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more