Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Checkboxes cannot be unchecked when used in JavaScript Calculation

New Here ,
Sep 08, 2021 Sep 08, 2021

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?

TOPICS
Create PDFs , General troubleshooting , JavaScript , PDF forms
641
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Sep 08, 2021 Sep 08, 2021

To compare values you must use ==, not only =

E.g.:

if (getField("Checkbox1").value == 1){

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2021 Sep 08, 2021

To compare values you must use ==, not only =

E.g.:

if (getField("Checkbox1").value == 1){

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2021 Sep 08, 2021
LATEST

Vielen Dank Bernd!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines