These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Checkbox conditional on value of another field

bren1519
Registered: Apr 28 2008
Posts: 27
Answered

Hi,
I have a form where we want the user to fill in the number of hours that they worked on a project. If the value is <=4 then I want Box A to be automatically ticked. If the value is >4 then I want Box B to be automatically ticked. If no hours are recorded both tick boxes should be blank
 
Appreciate the help!
Brenda

My Product Information:
Acrobat Pro 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
See this article on Conditional Execution

If this is an AcroForm, and the Boxes are check boxes, then this script will work when placed in the custom format script for the hours field

if((String(event.value) == "") || (event.value == 0))
{// No Entry
this.getField("BoxA") = "Off";
this.getField("BoxB") = "Off";
}
else if(event.value <= 4)
{
this.getField("BoxA") = "Yes";
this.getField("BoxB") = "Off";
}
else
{
this.getField("BoxA") = "Off";
this.getField("BoxB") = "Yes";
}




Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
In all the instances where Thom wrote:
this.getField("BoxA") = "Off";
it should have been:
this.getField("BoxA").value = "Off";

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

bren1519
Registered: Apr 28 2008
Posts: 27
Thx to both of you. I checked out the referenced link from Thom and with the correction added, the script you provided worked perfectly. Regards Brenda
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Opps, Thanks try67. I write that stuff just a little too fast;)

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script