Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Display / Hide Text Field based on drop box

Avatar

Level 2

Hi all,

First time post here - wahoo!  :-)  Brand new user to LiveCycle, and so far I'm loving it - very cool application!  I'm a little stumped though and hoping someone can help....

I'm using LiveCycle version 8.05, and trying to build a form that has a drop box with departments in our organisation.  If the user selects Items 1 - 5 on my list, I want two other fields to be autopopulated (one for Admin Assitant and one for Dept Head).  If however the user selects "Other", I want a text box to appear (it'll be hidden the rest of the time) where the person will be able to type in the department that they work for.  Right now I'm only focussing on getting the "Other" box to appear; I'll worry about the other stuff later.

Elsewhere in my form, I have a functioning drop box that displays a Text Field depending on the selection; however, for some reason this logic isn't working with the above situation.

My code for the working text field is (in JavaScript)

var

(sNewSel)
case "1":

switch

{

     TextField6.rawValue = "My text is in here";
break;
case "2":

= "My second text is in here ";

break;
"3":

case

= "My third text is in here.";
break;

TextField6.rawValue

default:

}

break;

TextField6.rawValue


sNewSel = this.boundItem(xfa.event.newText);

After many fruitless hours yesterday, I only got as far as the code below; this was more or less copied right out of a post here.  When I click the drop box selecting "Other", the Text Field doesn't display.  I have tried setting the text field to both "Hidden" and "Visible" through the object's properties, but no luck.  I've tried using IF Statements, Subforms, and anything else I could think of but am getting nowhere.

var nSubLength = Subform1.nodes.length;

var

sSelectField

for

{if

{switch (xfa.event.newText)

(case "6":

Subform1.nodes.item(nCount).presence

break

default:

Subform1.nodes.item(nCount).presence

break

}

}

}

;
= "invisible";
;
= "visible";
((Subform1.nodes.item(nCount).className ==
"field")
&(Subform1.nodes.item(nCount).name== sSelectField))

(var nCount = 0;
nCount
< nSubLength;
nCount
++)
sSelectField = fieldList.rawValue;
= sSelectField.replace(' ', '');

Any ideas?  This is all very new to me, but I'm familiar with other programming languages, and something this simple shouldn't be this difficult, which leads me to think I'm missing something.

Thanks in advance

Chris

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

It was easier to create a sample for you ...please see the attached file.  I think this is what you want.

The code is on the change event of the DDList

Paul

View solution in original post

6 Replies

Avatar

Correct answer by
Former Community Member

It was easier to create a sample for you ...please see the attached file.  I think this is what you want.

The code is on the change event of the DDList

Paul

Avatar

Level 2

Hi Paul - thank you thank you thank you!!!!!!!  That's exactly what I was trying to accomplish.  You've saved me from wasting time and my sanity!  (well, maybe not my sanity - that's been gone for a while :-))

Have a great day

Chris

Avatar

Level 2

....insert sheepish expression here...

Hi Paul (or anyone else)

The form you uploaded works perfectly; however, when I try the same thing on my form, the hidden text box still does not display.  I've read through more posts and have ensured everything is the same; I changed my Form properties from Adobe 7 Static to Dynamic, changed my field type to XHTML, and still nothing.  The only other thing I've noticed that's different is your form is version 9, whereas mine is 8.  If that is causing my problem, how do I go about fixing this?  If it's not, do you have any other suggestions?  I even copied your code from the Change event directly to my form, changed the names to match your code, and still nothing.  I know the code works though because the other options autopopulate the form accordingly, and

case ("Other"):

AdminAsst.rawValue

= "ffff";

DeptHead.rawValue

= "";

Department.presence

= "visible"

break;

Puts the ffff into the AdminAsst field.  In your code, there's no ";" after the "visible" but I've tried it both with and without, no such luck.

Any ideas?  Once again your time is appreciated...........

Chris

Avatar

Former Community Member

Are the fields getting populated if I choose a 1-5 value? In Designer cright click on the Preview tab and ensure that the Dynamic option is on. This display indicates which format your file has been saved as. If it is static do a saveAs and make it dynamic.

If that is not the issue ...then can you send me your form and I will have a look. Send it to LiveCycle8@gmail.com

Paul

Avatar

Level 2

*mutters under breath*

Yup, that was the problem.  So what's the difference between going under File -> Form Properties -> Defaults and setting it there versus going to Save As?  I had set the Form Properties as Adobe 7 Dynamic, but that obviously didn't fix the issue.

Again - thank you thank you thank you!!!

Chris

Avatar

Former Community Member

When you save the file from Designer a processing instruction is written into the file. This instruction overrides all others. That is why the one in the Form Properties is being ignored.

Paul

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----