简体   繁体   English

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

[英]LiveCycle drop-down list reference another field in an If statement

I have 2 drop-down lists, both of which offer the choice of Other . 我有2个下拉列表,它们都提供“ 其他”的选择。 When Other is chosen, a text field ("Other") becomes visible. 其他的选择,一个文本字段(“其他”)变得可见。 If a different option is chosen, the field is hidden. 如果选择了其他选项,则该字段将被隐藏。 But I don't want the field hidden when the different option for list "Tool" is chosen, if list "Cut" is displaying Other (or vice-versa). 但是,如果列表“ Cut”显示其他 (反之亦然),则当列表“ Tool”的其他选项被选择时,我不想隐藏该字段。 Clearly I'm missing something here: 显然我在这里缺少了一些东西:

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";
    }
}

If you want the "Other" textfield to show up only if BOTH options are other, then you need something like this in both drop down lists' exit event. 如果仅当两个选项都是其他选项时才希望显示“其他”文本字段,则在两个下拉列表的退出事件中都需要类似这样的内容。

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

Using the exit event will work just as well as the "change" event as long as you have "Commit On: Select" chosen in the Object palette. 只要在对象面板中选择了“提交时:选择”,使用退出事件就和“更改”事件一样有效。 That's the default option. 这是默认选项。

If you only want it visible if EITHER of the drop down lists shows "Other" then you want this code: 如果您只希望下拉列表中的EITHER显示为“ Other”,那么您需要以下代码:

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

I was not able to make your answer work, jasotastic, but there's a lot about scripting I don't understand. 我无法使您的答案发挥作用,这非常困难,但是我不了解脚本的很多知识。 However, this has worked for me (checking "Specify Item Values" on the Binding tab, where the list choice 'Other' has a value of 4): 但是,这对我有用(在“绑定”选项卡上选中“指定项目值”,列表选项“其他”的值为4):

var othercut = Cut.rawValue

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

This would be for the "Tool" dropdown; 这将用于“工具”下拉列表; corresponding changes are made in the "Cut" dropdown. 在“剪切”下拉菜单中进行了相应的更改。

I had tried going with logic operators before and got nowhere. 我以前尝试过使用逻辑运算符,但是一无所获。 I really do like the formula that works in the both cases, though. 不过,我确实很喜欢在两种情况下均有效的公式。

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

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