Expand my Community achievements bar.

subform visibility

Avatar

Level 1

Hi

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.

Thanks !!

4 Replies

Avatar

Former Community Member

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.

Paul

Avatar

Level 1

Paul,

Looks like that did the trick.

since my problem was not in the javascript but rather the choice of event (change vs exit), any reccommendation on a good read for general info on events (which events happen when, etc).

Thanks for you time & help.

Gordon

Avatar

Former Community Member

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:

http://forums.adobe.com/thread/522229

Paul

Avatar

Level 10

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);
switch (newValue)
{
    case "3":
        OtherLegislation.presence="hidden";
        InterestPeriod.presence="visible";
        InterestRate.presence="visible";
    break;
    case "4":
        InterestPeriod.presence="hidden";
        InterestRate.presence="hidden";
        OtherLegislation.presence="visible";   
    break;
    default:
        OtherLegislation.presence="hidden";
        InterestPeriod.presence="hidden";
        InterestRate.presence="hidden";   
}