Highlighted

Making another field visible based on the value selected in a drop-down box

_Bill_Bain_

02-06-2008

I have a form in which I would like one field ("BillingID") to become visible if the value in an adjacent dropdown box ("Doc_type") equals a certain value, but otherwise to remain invisible. Although the Doc_type drop down text choices are more verbose, I've assigned the values A and B to the choices to simplify codinglater, if that makes a difference. The field BillingID's presence is set to "invisible" when the form is opened.



Below is a copy of the text in the script editor containing the code I've tried, but it has no effect. I've set the form to dynamic PDF and the scripting language to Javascript. This is in Adobe Designer 7. I'm sure that there's something trivial I'm missing, but I've spent the last several hours on this and gotten nowhere. Any help greatly appreciated!



----- form1.#subform[0].Doc_type::change - (JavaScript, client) ----------



If(form1.#subform[0].Doc_type.Value == "B")

{form1.#subform[0].BillingID.presence = "visible"}

Else

{form1.#subform[0].BillingID.presence = "invisible"}

Replies

Highlighted

pmcalex

02-06-2008

I have successfully used the following code on one of my forms (but I am using version 8). It is simple (no assigning of values) but it may give you a starting point anyway.



For clarification, "Other" is the actual text of my list item choice.



Just add this to the change event of your drop down list replacing "Other" with the actual text of your "Value B" list item:



if (xfa.event.newText == "Other")

{form1.#subform[0].BillingID.presence = "visible";

}

else

{form1.#subform[0].BillingID.presence = "invisible";

}



Good luck 🙂
Highlighted

_Bill_Bain_

02-06-2008

Thanks for the help. I enabled the debugger (why that wasn't in the on-line help, I'l never know, but I found it on this site). Here's the error message I get in the debugger:



SyntaxError: illegal character

2:XFA:form1[0].#subform[0].DocType[0]:change



Here's the text from the Script Editor:



----- form1.#subform[0].DocType::change - (JavaScript, client) -------------------------------------



if (xfa.event.newText == "Amendment")

{form1.#subform[0].BillingID.presence = "visible";

}

else

{form1.#subform[0].BillingID.presence = "invisible";}



I'm clueless . . . .
Highlighted

pmcalex

02-06-2008

I've attached the actual code that is working in my form (in case you see something else in it that might help you). Since I have only been using LiveCycle Designer v8 for a very short time I'm unable to provide further assistance with your error. Sorry, I know how frustrating it can be. Hopefully someone else can offer assistance.



----- form1.Page1.sfColumn2.cboTimeOffense::change: - (JavaScript, client) -------------------------



if (xfa.event.newText == "Other"){form1.Page1.sfColumn2.txtSpecifyTimeOff.presence = "visible";

}

else



{form1.Page1.sfColumn2.txtSpecifyTimeOff.presence = "invisible";

}
Highlighted

_Bill_Bain_

02-06-2008

The only real difference I see is that your first line contains a colon after "change" adn mine does not. That line is inserted automatically by the S/W so I don't know if it's an issue or not.



Thanks for the help.
Highlighted

_Bill_Bain_

02-06-2008

OK, I got it. I used a "switch" statement on xfa.event.newText and it works fine. However, what's odd is that I used the "if...else" conditional with it, like you suggested and it worked fine as well. Why it didn't work before I haven't a clue.