Copy link to clipboard
Copied
Hi, I found this post https://community.adobe.com/t5/acrobat/trying-to-use-checkboxes-for-conditional-math/m-p/12008195#M3...
that is exactly what i need, a 'smart' script that will know if bonus is applied or not. Is it possible? I tried both codes from @Thom Parker and @try67 but they are not doing what I need,they are not taking into consideration if value is already applied or not, and also with try67 code if checked checkbox is auto unchecked. Can someone pls help?
My fields are "Text1" and "Check Box1"
There is a way to achive what you ask using variables.
Let's say you want to add 5 as a bonus, use this script in text field as custom calculation:
var a = 0;
var b = 0;
if(this.getField("Check Box1").valueAsString != "Off"){
var x = 1;
a = 5;}
if(x==1 && this.getField("Check Box1").valueAsString == "Off"){
b = -5;
x = 0;}
event.value = +event.value + a+b;
Even if you change value in text field it will add/remove bonus depending on checkbox state.
Copy link to clipboard
Copied
There is no such thing as smart script, script can't think it only do what you order it to do, so there is no way that script can know if you applied bonus or not.
Copy link to clipboard
Copied
There is a way to achive what you ask using variables.
Let's say you want to add 5 as a bonus, use this script in text field as custom calculation:
var a = 0;
var b = 0;
if(this.getField("Check Box1").valueAsString != "Off"){
var x = 1;
a = 5;}
if(x==1 && this.getField("Check Box1").valueAsString == "Off"){
b = -5;
x = 0;}
event.value = +event.value + a+b;
Even if you change value in text field it will add/remove bonus depending on checkbox state.
Copy link to clipboard
Copied
Thank you so much.