Indicate if checkbox ticked for multiple fields using getNthFieldName
I have created an Action script to place an X in text fields on page 1 if a corresponding check box is ticked which is located on other pages of the document.
The pdf file has multiple text fields on page 1 with the name of the text field beginning with C1.
In the rest of the document there are multiple check boxes with the name of the check box beginning with C1.
There are the same number of text fields and check boxes.
If the first check box is ticked, then the first text box on page 1 should then have an X in the field.
If the second check box is ticked, then the second text box on page 1 should then have an X in the field etc.
I am unsure how to capture the check box as a variable into the text field, if anyone can provide assistance that will be most appreciated.
for (var i = 0; i < this.numFields; i++) {
var fname = this.getNthFieldName(i);
var f = this.getField(fname);
if (fname==null) continue;
if ( f.type == "checkbox" && fname.substring(0,2) === "C1") {
console.println("checkbox " + this.getNthFieldName(i));
}
else if ( f.type == "textbox" && fname.substring(0,2) === "C1"){
console.println("textbox " + this.getNthFieldName(i));
var check = this.getField(??);
var cbStatus = (check.isBoxChecked(0));
if (cbStatus == 1) {
event.value = "X";
}
if (cbStatus == 0) {
event.value = "";
}
}
}
