Hi, I am new to LiveCycle and form designing. I have a form where I would like some fields to appear based on what was selected in a drop down list. For instance, if the user chooses "New Hire" from the drop down list in the field "Type", then I want additional fields to appear on the form. If they choose "Termination" in the drop down list the additional fields will not appear.
I do not have a database associated with the form. This form will be used for email only.
I tried creating a Choice Subform Set but didn't know how to write the expression to turn on/off the subform and it's imbedded fields.
Any help would be appreciated.
Views
Replies
Total Likes
If there is a small number fo fields involved I woudl simple toggle the presence property of each object. The states that you want to set it to are visible/invisible. So your code woudl look something like this:
if (checkbox1.rawValue == 1){
field1Name.presence = "visible"
field2name.presence = "visible"
field3name.presence = "invisible"
} else {
field1Name.presence = "invisible"
field2name.presence = "invisible"
field3name.presence = "visible"
}
Paul
Views
Replies
Total Likes
There are not many fields on the form so I think this well could be the answer. Unfortunately, newbie that I am, I don't know where to put the code. Sorry to be such an ignoramus.
Views
Replies
Total Likes
On the change event of the checkbox in question
Paul
Views
Replies
Total Likes
And how do I access this change event for my drop down list field? I am attaching a document with a screen shot of my doc in LiveCycle.
Views
Replies
Total Likes
Sorry I thought it was a checkbox you were using. Make sure the dropdown is highlighted. Open the Script editor (Ctrl-Shift- F5) if it is not. On the top left is a Show dropdown. This is a list of all available events for this object. Choose the Exit event. On the top right of the script editor is the language and Run At setting. Make sure you choose Javascript and Client respectively.
Now you can write your code
Views
Replies
Total Likes
Attached is a view of my script. The resident checkbox is always visible no matter what I choose in the Type drop-down list.
Views
Replies
Total Likes
Is your form saved as dynamic? If that still does not work post the form and I will have a look.
Paul
Views
Replies
Total Likes
Your help has been invaluable and I am so close. I saved the document as dynamic and the script performed correctly. Now I want to add additional criter ia to the script similar to a case statement. When Type = New Hire" then this, when Type = "Termination" then that. I am attaching a sample of how I tried to write the script but obviously I am wrong. Would you please take a look at it?
Thx
Views
Replies
Total Likes
So why not use a javascript switch statement (similar to a case statement):
switch (expression)
{
case label1:
statement1;
statement2;
.....
break;
case label2:
statement1;
statement2;
.....
break;
default:
statement1;
statement2;
.....
break;
}
In your case it would look something like this:
switch (Type.rawValue)
{
case "New Hire":
Resident.presence = "visible";
......
break;
case "Termination":
Resident.presence = "visible";
......
break;
default:
Resident.presence = "visible";
......
}
Views
Replies
Total Likes
Thank you for sticking with me on this. I was able to write the script with the results I wanted.
Views
Replies
Total Likes
Views
Likes
Replies