Pregunta

I have 2 drop-down lists, both of which offer the choice of Other. 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). 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";
    }
}
¿Fue útil?

Solución 2

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):

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.

Otros consejos

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:

if(Tool.rawValue == "Other" || Cut.rawValue == "Other") Other.presence = visible;
else Other.presence = "hidden";
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top