I'm trying to make a subform visible or invisible based on the user-selected value in a dropdown list. I thought this was clear after reading the help file.
I've got the presence prperty of the subform set to invisible and I'm using the following code in the change event of the drop down list (assume the dropdown list has only three values; a default "Select", and two choices "foo" and "bar")
if ( dropDownList.rawValue == "foo" )
subform.presence = "visible";
if( dropDownList.rawValue == "bar" )
subform.presence = "invisible"
if( dropDownList.rawvalue == "Select" )
subform.presence = "invisible";
The symptom is that the subform is invisible when the form is opened (as expected) but does not change to visible until I select "foo" twice from the dropdown list.
Am I missing something obvious? Maybe there is a bug? i'm using designer 8.0 because I'm on an enterprise and can't upgrade.
My guess is that you have your code on the change event. The value for the dropdown is not committed until you leave the field. So move your code to the exit event and it shodul work the way you want.
Looks like that did the trick.
Thanks for you time & help.
There are a number of good books that have been published (do a serach for LiveCycle Designer books) and you will get a list. There was also a post by Niall O'Donavan on this forum that had a sample that shows how the events work and their sequence. Here is a link to that psot:
I like using the Change event so if you arrow up or down through the list you get immediate feedback. You can do this using boundItem().
For a series of changes like you have I prefer using a switch() statement too - makes things easier to read. I'm using the "specified value" in the sample below, but you can put the text from the dropdown choices in there too.
var newValue = this.boundItem(xfa.event.newText);