首页 > 解决方案 > 检查生成的页面模板上的所有复选框

问题描述

我创建了一个带有页面模板的表单,当用户选择表单上的复选框时会生成这些模板。其中一个页面模板有一个复选框列表,后跟“全选”复选框。选中此项后,所有复选框都会自动选中。这在页面模板上工作正常,但是当生成模板时,“全选”复选框之间的“链接”被破坏,并且没有选择其他复选框。这是我到目前为止的javascript:

if(event.target.isBoxChecked(0))
{// Perform actions when checked
   this.getField(“A”).checkThisBox(0,true);
   this.getField(“B”).checkThisBox(0,true);
       this.getField(“C”).checkThisBox(0,true);
       this.getField(“D”).checkThisBox(0,true);
       this.getField(“E”).checkThisBox(0,true);
       this.getField(“F”).checkThisBox(0,true);
       this.getField(“G”).checkThisBox(0,true);
    }
else
{// Perform actions when unchecked
   this.getField(“A”).checkThisBox(0,false);
   this.getField(“B”).checkThisBox(0,false);
       this.getField(“C”).checkThisBox(0,false);
       this.getField(“D”).checkThisBox(0,false);
       this.getField(“E”).checkThisBox(0,false);
       this.getField(“F”).checkThisBox(0,false);
       this.getField(“G”).checkThisBox(0,false);
}

标签: javascriptformstemplatespdfcheckbox

解决方案


感谢大家的意见。我找到了一个完美的线程: 

var cPreFix = "";
// get prefix elements for spawned pages;
var aFieldName = event.target.name.split(".");
if(aFieldName.length > 2)
{
// first 2 elements of name array makeup the prefix for fields on a spawned page;
cPreFix = aFieldName[0] + "." + aFieldName[1] + ".";
}
//if/else conditional statement
if(event.target.isBoxChecked(0))
{// Perform actions when checked
  this.getField(cPreFix +"Option1").checkThisBox(0,true);
  this.getField(cPreFix +"Option2").checkThisBox(0,true);

  this.getField(cPreFix +"Option3").checkThisBox(0,true);

else
{// Perform actions when unchecked
  this.getField(cPreFix +"Option1").checkThisBox(0,false);
  this.getField(cPreFix +"Option2").checkThisBox(0,false);

  this.getField(cPreFix +"Option3").checkThisBox(0,false);
}

感谢 adobe 社区论坛的 gkaiseril:acrobat/how-do-i-have-calculated-scripts-adjust-when-i-spawn-a-new-page-from-a-template/ [https://community. adobe.com/t5/acrobat/how-do-i-have-calculated-scripts-adjust-when-i-spawn-a-new-page-from-a-template/mp/9902135?page=1]


推荐阅读