简体   繁体   English

Adobe Acrobat Pro-下拉列表,显示和隐藏javascript中的值

[英]Adobe Acrobat Pro - Drop down list, show and hide values in javascript

I am using Adobe Acrobat Pro for my PDF form. 我的PDF表单使用的是Adobe Acrobat Pro。 I would like to hide and show values, depending on the values selected in the drop down box. 我想隐藏和显示值,具体取决于在下拉框中选择的值。

My problem. 我的问题。 I need to select the same value twice, before it actually functions the way i want. 我需要选择两次相同的值,然后它才能真正发挥所需的功能。 It seem like it does not get the selected value immediately. 似乎无法立即获得所选值。

The drop down box is working, it's just the JavaScript for hiding and showing values that is not working properly. 下拉框正在运行,只是用于隐藏和显示无法正常工作的值的JavaScript。

Any help would be appreciated. 任何帮助,将不胜感激。

(function () {
var v = getField("Combo Box2").value; 
if (v === "031 Rotvoll Bygg A") {
    this.getField("ByggC").display = display.hidden;
    this.getField("ByggA").display = display.visible;
    return;
} else if (v === "033 Rotvoll Bygg C") {
    this.getField("ByggA").display = display.hidden;
    this.getField("ByggC").display = display.visible;
    return;
} else {
    this.getField("ByggA").display = display.visible;
    this.getField("ListBox2").display = display.visible;
    this.getField("ByggC").display = display.visible;
    return;
}

})(); })();

In the options panel, check the box that says "Commit selected value immediately" then add your code to the Custom Format Script of the dropbox but don't wrap it in a function. 在选项面板中,选中“立即提交选定的值”复选框,然后将代码添加到保管箱的“自定义格式脚本”中,但不要将其包装在函数中。 It should be just... 应该只是...

var v = this.getField("Combo Box2").value; 
if (v === "031 Rotvoll Bygg A") {
    this.getField("ByggC").display = display.hidden;
    this.getField("ByggA").display = display.visible;
} else if (v === "033 Rotvoll Bygg C") {
    this.getField("ByggA").display = display.hidden;
    this.getField("ByggC").display = display.visible;
} else {
    this.getField("ByggA").display = display.visible;
    this.getField("ListBox2").display = display.visible;
    this.getField("ByggC").display = display.visible;
}

The custom format script runs only when the value changes so that's when you'll know the drop box value has the value you selected. 自定义格式脚本仅在值更改时才运行,因此您将知道投递箱值具有所选值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM