Copy link to clipboard
Copied
Hey there-- I have a simple choice selection, ordering PDF.
Working with Acrobat PRO DC
There are 31 choices but I need a "must equal to" on how many choices can be made.
As choices are made a visible tally box calculates total choices made.
FYI, 30 of the choices have a value of 1. One choice has a value of 5.
FYI, I have no experience with this or javascripting. Thanks for the understanding.
Here is the basic argument for validation:
Selection total (Card Total)
must be equal to 1
or must be equal to 5
Additional arguments:
Selection total cannot be 0 (zero)
Selection total cannot be between 1 and 5 (2, 3 or 4)
Selection total cannot be greater than 5
I also need a validation warning when argument is not met.
Will Acrobat do that automatically with script in place?
Thanks again for the understanding.
Scott
Copy link to clipboard
Copied
Just checking to see if I'm understanding this right:
Could you not use radio buttons for this? and then use a Text Field that basically is a read only field in which the value of the selected radio button is displayed?
And make the radio button a required field?
Copy link to clipboard
Copied
Hi Cari,
You can choose either 1 or 5, BUT that "5" can be from the checkboxes that have a value of 1 assigned.
The ONE that has a value of 5 is already a fixed set of 5 items-- so it negates ability to choose more.
So in practice, there is a choice of only 1 item, or a single set of 5 (value 5) OR 5 different items (value 1 each).
Meaning that one checkbox can be displayed for value 1 or the set of 5, or 5 separate checkboxes.
Is that clearer?
Scott
Copy link to clipboard
Copied
It's easy enough to write a script that does some kind of validation on a running total. Use the same script that is in the Total box.
If all you want to do is indicate an invalid selection, then this is easy. This indication could be a color change of the total box (Red for invalid and green for valid) and display a status message in a text box.
Now the trick to adding the checkboxes is to name them for easy access. The best method is to use a group name.
For example "Sel.num1", "Sel.num2", etc. The "Sel" is the group name. This script will work for adding them. Put it in the calculation script for the Total field
var flds = this.getField("Sel").getArray();
var sum = 0;
for(var i=0;i<flds.length;i++)
{
if(!isNaN(flds.value))
sum+=flds.value;
}
if((sum==1)||(sum==5))
{
this.getField("Status").value = "All OK";
}
else
{
this.getField("Status").value = "Invalid Selections";
}