Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Problem with subform (hidden & visible)

Avatar

Former Community Member
I am new to Javascript but feel embarrassed to ask since I have some programming background. Putting my pride behind me. I am trying to use a drop down list ("A" & "B") that will hide or make visible two subforms ("Subform1" and "Subform2"). This is pretty basic but I can not get it to work. Any suggestions?



if (this.rawValue == "A")

{

Subform1.presence = "visible";

Subform2.presence = "hidden";

}

else if (this.rawValue == "B")

{

Subform1.presence = "hidden";

Subform2.presence = "visible";

}
13 Replies

Avatar

Former Community Member
The script looks OK ...what event do you have the code running on?



Also if you are using Acrobat to test with you can hit Ctrl-J and see the javascript console ..which will report any errors in your script when it runs.

Avatar

Former Community Member
Paul can I send you the pdf file to look at?

Avatar

Former Community Member
Event:



form1.Page1.DropDownList1::exit - (JavaScript, client)



No errors in javascript console.

Avatar

Level 4
Add the line



console.println ("" +this.rawValue);



Just before your presence changing code, just to check what value it is set to when you are running it. It might not have changed at the time you are running the code.



Tom

Avatar

Former Community Member
Thomas adding code did not fix problem. I would love to send pdf to someone to figure out what's going on. Any takers?????

Avatar

Former Community Member
Send it to livecycle8@gmail.com and I will have a look.

Avatar

Former Community Member
As a general recommendation (since it's hard to debug in PDF), write code like this to trace the values before (or after) your code:



xfa.host.messageBox("RawValue: " + this.rawValue + "\nFormattedValue: " + this.formattedValue);

The messagebox will tell you if your values are what you expect them to be or not.

Avatar

Former Community Member
Problem solved by Paul. I did not save the form as a dynamic form. Thanks Paul. At least my code worked..... ;-)

Avatar

Former Community Member
Hi,



I have the same problem even the form is save as a dynamic form but I am using Switch case as below:



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



switch (sNewSel)

{

// Option 1 - Out-of-Agency Training

case "Out-of-Agency Training (Send to D/D/O Training Coordinator)":

xfa.resolveNode("Form1750.MainPage.SubSignature.EmployeeSig").presence = "visible";

xfa.resolveNode("Form1750.MainPage.SubSignature.EmpDate").presence = "visible";

xfa.resolveNode("Form1750.MainPage.SubSignature.CommSig").presence = "invisible";

xfa.resolveNode("Form1750.MainPage.SubSignature.CommDate").presence = "invisible";



break;



... option 2

.... option 3

..... option 4



}



It works at first but it does not after the form is submitted as all of the fields are visible.



Any help would be appreciated.



Thanks in advance,

Han Dao

Avatar

Level 2
Is there not a feature in LCD-ES-8 where you can display a subform or a group of fields only if the user enters a particular value for a field without writing code?

Avatar

Former Community Member
Hi,



Well, it was working before but as the form get more complicated by adding the web services for populating data from the database, it just doesn't work right. It works in the begining when other fields in the form is not populated yet but then when these fields got populated, then the drop down list seem like to reset to its original state by making all the fields are visible. Could any help please help.



Thanks again,

Han Dao

Avatar

Level 10
I'm having a similar problem getting subforms to appear/disappear. My script code checks out to all the samples I've got (including JP Terry's book), form is saved as dynamic, etc., but the subforms just won't cooperate. It's driving me nuts!