javascript - 检查生成的页面模板上的所有复选框
问题描述
我创建了一个带有页面模板的表单,当用户选择表单上的复选框时会生成这些模板。其中一个页面模板有一个复选框列表,后跟“全选”复选框。选中此项后,所有复选框都会自动选中。这在页面模板上工作正常,但是当生成模板时,“全选”复选框之间的“链接”被破坏,并且没有选择其他复选框。这是我到目前为止的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);
}
解决方案
感谢大家的意见。我找到了一个完美的线程:
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]
推荐阅读
- git - git bitbucket 版本中的基本分支与默认分支
- android - 上传构建工件、多个应用程序的常见任务
- php - 如何识别可用的 SOAP 函数?
- java - 在 Groovy 中编码时,“->” lamda 运算符有什么问题?
- python - 在日志中找到特定字符串时停止子进程
- javascript - REST API - CORS 问题
- nginx - Nginx - 如何创建将与 auth_request 模块一起使用的自定义请求
- java - 如何将 ArrayList 存储在文件中?
- python - 如何减小 5 层 for 循环的大小
- python - 考虑比例因子获取屏幕像素