【问题标题】:How do I edit text fields based on checkmarks with JavaScript in Adobe Acrobat?如何在 Adob​​e Acrobat 中使用 JavaScript 编辑基于复选标记的文本字段?
【发布时间】:2021-09-08 16:48:56
【问题描述】:

我正在尝试根据选中的复选标记更改 Adob​​e Acrobat 中 PDF 文档中的文本字段。这是我的表单如下所示:

我已将以下脚本添加到两个复选框中,以在“鼠标上移”时执行:

var checkbox1 = event.target.isBoxChecked(0);
var checkbox2 = event.target.isBoxChecked(1);

if (checkbox1 && checkbox2){
    this.getField("Text1").value = "1 and 2";
} else if (checkbox1) {
    this.getField("Text1").value = "Just 1";
} else if (checkbox2) {
    this.getField("Text1").value = "Just 2";
}

我在想这个脚本会记录单击其中一个复选框时选中的复选框,然后相应地调整文本框,但没有任何反应。保存脚本时,我也没有收到任何语法错误。任何帮助将不胜感激。

【问题讨论】:

    标签: javascript checkbox adobe acrobat


    【解决方案1】:

    想通了。我能够通过放弃“event.target”对象来完成我正在寻找的东西,而是直接按名称抓取复选框,就像我对文本框所做的那样。这是代码:

    if (this.getField("Checkbox1").isBoxChecked(0) && this.getField("Checkbox2").isBoxChecked(0)) {
        this.getField("Text1").value = "Both";
    } else if (this.getField("Checkbox1").isBoxChecked(0)) {
        this.getField("Text1").value = "Just 1";
    } else if (this.getField("Checkbox2").isBoxChecked(0)) {
        this.getField("Text1").value = "Just 2";
    } else {
        this.getField("Text1").value = "Neither";
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-01
      • 2016-08-31
      • 2023-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多