What code can I use to auto populate a text field if a checkbox has been activated?

I am creating an editable PDF form to use for estimates. It has a series of check boxes for items that we often include in estimates. I would like to incorporate a code so that if for example the concrete check box is clicked a separate text field auto populates with a description of the work.


Kelsey Halvarson


3 Answers

Voted Best Answer

Supposing your Check Box field is named as “concrete” and the corresponding text field is read only, you can add the following script as a Custom calculation script to the text field:

var v = this.getField("concrete").value; //change field name as needed
event.value = "";

if(v != "Off"){
    event.value = "Service Description..."; //change text as needed
}

enter image description here


By Almir R V Santos   

If you have multiple check boxes that are mutually exclusive, that is, only one can be checked in the series, then you would name them all the same and change the export values to the description of service. Then, using the same field names as Almir, change the script as follows:

if (this.getField("Concrete").value!="Off")
{event.value=this.getField("Concrete").value}
else
{event.value=""}

Where Concrete is the name of the series of check boxes and the export values are the service descriptions.


David Dagley   

Considering David's idea, I would name all the check boxes as "options", for example, and change their export values to "concrete", "trees", "patio bricks", etc., and keep only one text field to show the description of the work. In this scenario, you can add the following script as a Custom calculation script to the text field:

var v = this.getField("options").value;
event.value = "";

if(v == "concrete"){
    event.value = "Concrete Service Description...";
}
else if(v == "trees"){
    event.value = "Trees Service Description...";
}
else if(v == "patio bricks"){
    event.value = "Patio Bricks Service Description...";
}

enter image description here

enter image description here

enter image description here


Almir R V Santos   


Please specify a reason: