Skip to main content
Participant
June 1, 2023
Question

Help populating text box from checkboxes

  • June 1, 2023
  • 1 reply
  • 183 views

I have a fillable PDF with 10 checkboxes (not radio buttons).

 

If one or more of the checkboxes are selected, I want 'Yes' to be populated in a text box.

 

I tried adding the below code to the calculation section of the text box, but its not working. Nothing is added when checking any of the boxes. Any suggestions?

 

var cb1 = this.getField("Issue1").value;
var cb2 = this.getField("Issue2").value;
var cb3 = this.getField("Issue3").value;
var cb4 = this.getField("Issue4").value;
var cb5 = this.getField("Issue5").value;
var cb6 = this.getField("Issue6").value;
var cb7 = this.getField("Issue7").value;
var cb8 = this.getField("Issue8").value;
var cb9 = this.getField("Issue9").value;
var cb10 = this.getField("Issue10").value;
if (cb1 == "Yes" || cb2 == "Yes" || cb3 == "Yes" || cb4 == "Yes" || cb5 == "Yes" || cb6 == "Yes" || cb7 == "Yes" || cb8 == "Yes" || cb9 == "Yes" || cb10 == "Yes"){this.getField("IssueTextBox").value = "Yes";}
else {this.getField("IssueTextBox").value = "";}

This topic has been closed for replies.

1 reply

JR Boulay
Community Expert
Community Expert
June 1, 2023

Try this script, as a Calculation script in the text form field:

 

var nCount = 0;
for (var i = 1; i < 11; i++) {
if (this.getField("Issue" + i).value != "Off") {nCount = nCount + 1;}
}
if (nCount != 0) {event.target.value = "Yes";}
else {event.target.value = event.target.defaultValue;}

Acrobate du PDF, InDesigner et Photoshopographe