Acrobat XI Pro:检查复选框的状态以影响计算

Acrobat XI Pro: checking status of a checkbox to affect calculation

本文关键字:状态 影响 计算 复选框 XI Pro 检查 Acrobat      更新时间:2023-09-26

我正在尝试将计算添加到其他人创建的表单中,但我有点卡在JS上。一组字段具有两种可能的计算,具体取决于关联的复选框是选中还是未选中。我如何 a) 检查以查看复选框的状态,以及 b) 是否会影响计算?

我知道对于 b 部分,

我将使用某种 if-else 语句,并且我已经有一些应该可以工作的编码,但 a 部分让我完全困惑。自从我上次做任何编码以来已经有一段时间了,所以我的技能和知识有点生疏。这是我到目前为止的代码:

//check bonus = stat bonus + applicable proficiency bonus
var profUse = this.getField("SavStrProf").value;
var stat = Number(this.getField("SavStrVal").value);
var profVal = Number(this.getField("Proficiency Bonus").value);
var check = Number('-2');
if (profUse == checked){
    check = stat + profVal;
}
else{
    check = stat;
}
event.value = check;

如果拥有我正在使用的PDF表单有帮助,您应该能够在此处找到它:http://www.enworld.org/forum/rpgdownloads.php?do=download&downloadid=1089

仔细查看 Acrobat Javascript 文档可能会很有用,该文档是 Acrobat SDK 的一部分,可从 Adobe 网站下载。

复选框有一个返回值;即选中它时的字段值。如果未选中,则其值始终为"关闭"。

测试(单个)复选框的最简单方法如下所示:

if (this.getField("myCheckBox").value != "Off") { 
   // the box is checked 
   // do what should be done when the box is checked 
} else { 
   // the box is not checked 
   // do what should be done when the box is not checked 
}

在许多情况下,明智地选择复选框的返回值可以简化计算。