Skip to main content
Participant
June 3, 2020
Answered

check box equals a value in form when checked

  • June 3, 2020
  • 1 reply
  • 12878 views

I am creating a form that adds amounts for a total. I want to create a check box (BOX1), that when checked, puts a specific dollar amount in another text box  (#4) which is then added to other amounts to create a total for purchase. 

This topic has been closed for replies.
Correct answer Thom Parker

right now the script is in the actions/run javascript in Box1 and the data in box4 is read only.


You mean that the script is on a MouseUp "run a JavaScript" on the Box1 checkbox?

Ok, then the script should look like this:

 

if (event.target.isBoxChecked(0))
      this.getField("BOX4").value = 4; 
else
      this.getField("BOX4").value = 0; 

 

 

1 reply

BarlaeDC
Community Expert
Community Expert
June 3, 2020

Hi,

Something like this should work for the checkbox part :

if (this.getField("BOX1").isBoxChecked(0)){
this.getField("BOX4").value = 4; // dollar amount
}

 

Then you can just calculate the fields as normal,

 

see here for more information - https://community.adobe.com/t5/acrobat/field-calculation/td-p/10314382?page=1

 

Regards

Malcolm

Participant
December 5, 2023

Hi, I'm trying to use nested if statements so that if they check one of 5 checkboxes the value is displayed as the total. It seems that one i get beyond 3 of the if statements, then it works for only the first and last if statement.

if (this.getField("1.0").isBoxChecked(0))
event.value = 0;
if (this.getField("1.1").isBoxChecked(0))
event.value = 1;
if (this.getField("1.2").isBoxChecked(0))
event.value = 2;
if (this.getField("1.3").isBoxChecked(0))
event.value = 3;
else
event.value = 0;

 

Bernd Alheit
Community Expert
Community Expert
December 5, 2023

Add else before the last 3 if