Copy link to clipboard
Copied
Hello everyone,
I have got a problem with checkboxes which are used to calculate the value of a field with a few lines of JavaScript code. This is the code I am using at the moment (I set the output values of the checkboxes to 1):
if (getField("Checkbox1").value = 1){
if(getField("Checkbox2").value = 1){
if(getField("Checkbox3").value = 1){
this.getField("Calculation").value = 1.1
}
}
}
After that I want to set the value to 1.0 if only 2 boxes are checked and then to 0.9 when only one is checked.
The calculation works fine but if I try to uncheck a checkbox after the calculation it will always re-check it as soon as I input another number in a random other field on the document. So I open the document and check all 3 boxes; calculation of value 1.1 works fine; I uncheck one of the boxes; input a number somewhere else on the document and the formerly unchecked box is now checked again without me doing it.
Can anyone help with this issue?
Copy link to clipboard
Copied
To compare values you must use ==, not only =
E.g.:
if (getField("Checkbox1").value == 1){
Copy link to clipboard
Copied
To compare values you must use ==, not only =
E.g.:
if (getField("Checkbox1").value == 1){
Copy link to clipboard
Copied
Vielen Dank Bernd!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more