【问题标题】:Acrobat XI Pro: checking status of a checkbox to affect calculationAcrobat XI Pro:检查复选框的状态以影响计算
【发布时间】:2015-08-10 03:36:14
【问题描述】:

我正在尝试将计算添加到其他人创建的表单中,但我有点卡在 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

【问题讨论】:

    标签: javascript checkbox acrobat


    【解决方案1】:

    仔细查看 Acrobat Javascript documentation 可能会有所帮助,它是 Acrobat SDK 的一部分,可从 Adob​​e 网站下载。

    复选框有返回值;这是检查时的字段值。未选中时,其值始终为“关”。

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

    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 
    }
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-10
      • 2017-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多