简体   繁体   English

在 Acrobat Javascript 中使用 if function 范围时出现语法错误

[英]Syntax Error when using range in if function in Acrobat Javascript

I'm trying to get a text field to disappear based on a previously calculated number with Javascript for Adobe Acrobat.我正在尝试根据之前为 Adobe Acrobat 计算的数字 Javascript 使文本字段消失。 I want the text field to disappear only if the number in the previous field is equal to, or greater than 0, or less than 75.我希望文本字段仅在前一个字段中的数字等于、大于 0 或小于 75 时消失。

I have no problems getting it to function if I only use less than 75, but when I try to introduce the range it fails.如果我只使用小于 75,我可以毫无问题地将它设置为 function,但是当我尝试引入范围时它失败了。

I'm using Custom calculation script in the field that changes visibility.我在更改可见性的字段中使用自定义计算脚本。

This script works:这个脚本有效:

if (this.getField("PreviouslyCalculatedField").value < 75) {
    event.target.display = display.hidden;
} else {
    event.target.display = display.visible;
    this.getField("FieldToChangeVisibility").value = "Hello world."
}

This is the script that fails:这是失败的脚本:

if (this.getField("PreviouslyCalculatedField").value >= 0 && < 75) {
    event.target.display = display.hidden;
} else {
    event.target.display = display.visible;
    this.getField("FieldToChangeVisibility").value = "Hello world."
}

It produces "Syntax Error: Invalid XML name.它产生“语法错误:无效的 XML 名称。

Acrobat JavaScript does not have an operator to combine limits in one if statement. Acrobat JavaScript 没有在一个if语句中组合限制的运算符。

You would use this statement:您将使用此语句:

if (this.getField("PreviouslyCalculatedField").value >= 0 && this.getField("PreviouslyCalculatedField").value < 75) {

and then it would work.然后它就会起作用。

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

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