LiveCycle下拉列表引用If语句中的另一个字段

时间:2014-04-23 20:53:28

标签: javascript if-statement livecycle

我有2个下拉列表,这两个列表都可以选择其他。选择其他时,文本字段("其他")变为可见。如果选择了其他选项,则隐藏该字段。但是,当列表"工具"的不同选项时,我不希望隐藏字段。如果列出" Cut"正在显示其他(反之亦然)。显然,我在这里遗漏了一些东西:

form1.RFQ.Body.RequiredItems.Table1.Row1.Col2.Types.Tool::change - (JavaScript, client)

if(xfa.event.newText == "Other"){
    Other.presence = "visible";
}

else{
    if (Cut.caption == "Other"){
        Other.presence = "visible";
    }
    else{
        Other.presence = "hidden";
    }
}

2 个答案:

答案 0 :(得分:0)

如果您希望“其他”文本字段仅在BOTH选项为其他选项时显示,则在下拉列表的退出事件中您需要这样的内容。

if(Tool.rawValue == "Other" && Cut.rawValue == "Other") Other.presence = visible;
else Other.presence = "hidden";

只要在对象选项板中选择了“Commit On:Select”,使用exit事件就可以和“change”事件一样工作。这是默认选项。

如果您只希望在下拉列表中显示“其他”时显示,则需要此代码:

if(Tool.rawValue == "Other" || Cut.rawValue == "Other") Other.presence = visible;
else Other.presence = "hidden";

答案 1 :(得分:0)

我无法让你的答案发挥作用,jasotastic,但是有很多关于我不理解的脚本。但是,这对我有用(在“绑定”选项卡上选中“指定项目值”,其中列表选项“其他”的值为4):

var othercut = Cut.rawValue

if(xfa.event.newText == "Other"){
    Other.presence = "visible";
}
else{
    if (othercut == 4){
        Other.presence =  "visible";
    }
    else{
        Other.presence = "hidden";
    }
}

这将是“工具”下拉列表;相应的更改在“剪切”下拉列表中进行。

之前我曾尝试使用逻辑运算符而无处可去。不过,我确实喜欢在这两种情况下都适用的公式。