Check a checkbox in an array based on numerical value.

I want to check one of several checkboxes all having the same name, "checkbox." Each has a separate export value (1-49, 50-99, etc.). I was thinking of using a validation JS in field1, whose value checkbox describes. If field1.value equals 42, for example, I want checkbox 1-49 checked.

So I was thinking of using this validation JS in field1:

if(getField("field1").value < 50) this.getField("checkbox[1]").checkThisBox(0, true);
else this.getField("checkbox[2]").checkThisBox(0, true);

However, it isn't working. Thoughts? Thanks everyone!


Jeremy Cobb


2 Answers

Voted Best Answer

Read the reference of the checkThisBox method...

.


Visit my custom-made PDF scripts website: http://try67.blogspot.com
Contact me personally: try6767@gmail.com


By Gilad D (try67)   

There are several problems with your code. But rather than explain these issues I think it is better to start with an explanation.

A check box is checked when the value of the check box field (group of check boxes with the same name) is the same as the export value a particular check box widget (individual check box). So your best strategy is to use the export value.

Here is a script for the validation script in "Field1"

if(event.value < 50)
       this.getField("checkbox").value = "1-49"; 
else 
      this.getField("checkbox").value = "50-99"; 

Thom Parker
The source for PDF Scripting Info pdfscripting.com
All About PDF Stamps in Acrobat and Paperless Workflows - THE BOOK !!

The Acrobat JavaScript Reference, Use it Early and Often

The most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

Having trouble, Why Doesn't my Script Work


Thom Parker   


Please specify a reason: