Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Problem with subform (hidden & visible)

Not applicable
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
pguerett
Level 10
Level 10
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.
Not applicable
Paul can I send you the pdf file to look at?
Not applicable
Event:



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



No errors in javascript console.
Not applicable
I will gladly send pdf to anyone.
Thomas_McConnac
Level 4
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
Not applicable
Thomas adding code did not fix problem. I would love to send pdf to someone to figure out what's going on. Any takers?????
pguerett
Level 10
Level 10
Send it to livecycle8@gmail.com and I will have a look.
Not applicable
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.
Not applicable
Problem solved by Paul. I did not save the form as a dynamic form. Thanks Paul. At least my code worked..... 😉
Han_Dao
Level 8
Level 8
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
DVDmike
Level 2
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?
Han_Dao
Level 8
Level 8
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
Jono_Moore
Level 10
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!