Copy link to clipboard
Copied
I have a series of data points in an Acrobat Form. I have two checkboxes, and if either one or both are selected, I need a value of 1. I am not good at Javascript, and I think I am missing the very simple way to do it.
Where are these data points (in a text box, a list box?),
How are they set, and what is the relationship to the check boxes. are there two checks boxes per data point?
Where is this "1" going to be.
Since the "1" value depends on two different inputs, a calculation script is a good place to put the code, because calculation scripts are run each time any field changes. So here's an example of a calculation script.
if((this.getField("check1").value == "Yes") || (this.getField("check2").value == "Yes
...Copy link to clipboard
Copied
Where are these data points (in a text box, a list box?),
How are they set, and what is the relationship to the check boxes. are there two checks boxes per data point?
Where is this "1" going to be.
Since the "1" value depends on two different inputs, a calculation script is a good place to put the code, because calculation scripts are run each time any field changes. So here's an example of a calculation script.
if((this.getField("check1").value == "Yes") || (this.getField("check2").value == "Yes"))
event.value = 1;
else
{ display the thing that gets displayed when it's not "1"}
Here's an old tutorial on setting up calculations:
https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations
Here's lots more recent info:
Calculating field values and more
Copy link to clipboard
Copied
Will that work if my checkboxes export a value of a number rather than "yes"? This is for an entry form, and I have 20 lines with 10 items in each line. I need a variety of calculations, and selecting the checkboxes calculate fees (two entries per line), but I need to count how many lines have at least one entry.
Copy link to clipboard
Copied
Wait! I got it!!!!
if((this.getField("A1").value == "4") || (this.getField("B1").value == "4"))
event.value = 1;
else
event.value = 0
This gives me "1" if A and/or B, and "0" if neither! Perfect! Thank you!