Expand my Community achievements bar.

Subform hiding/showing - 2 at once

Avatar

Former Community Member

Trying to design an interactive form using LiveCycle 8. Based on a question which has 3 possible answers I want to display 1 of 2 subforms. Both subforms are hidden by default. The problem arises when I change the selection from one option to another - the first form remains onscreen until a 3rd choice is made. So basically, it takes 2 changes to make a selection disappear with the possibility of 2 subforms being shown at the same time.

I have tried this using radio buttons and a drop-down list, and also applying the JavaScript to change or exit; but always have the same issue. The code I am using is:

if(this.rawValue == "Opt1")
{
    Opt1ServicesRequired.presence = "visible";
    OtherServicesRequired.presence = "hidden";
}
else if(this.rawValue == "Select...")
{
    Opt1ServicesRequired.presence = "hidden";
    OtherServicesRequired.presence = "hidden";
}
else
{
    Opt1ServicesRequired.presence = "visible";
    OtherServicesRequired.presence = "hidden";
}

This is the drop-down variant of the code. If I use radio buttons, I miss out the "else if" statement.

Any help on this would be greatly appreciated.

Thanks,

Neil

6 Replies

Avatar

Level 6

Here are few things to understand the property rawValue for any field is assigned when the focus is moved out of the field. In other words the chosen value is not really assigned until unless the curser is moved to another field. So when you have this kind of issues I recommend use this code on "change" event or "layout:ready" event rather than "exit" event. I would try the "change" event first based on the other implications with "layout:ready" event.

Avatar

Former Community Member

I originally had the code in the "change"event, but also had the same behaviour.

Am I right in thinking the "layout:ready" event only happens when the form is first displayed? In which case, I take it this would not be suitable for what I am trying to do given the selection that causes this code to run is made by the user?

Avatar

Level 2

Try this out, and i would recommend you use it in the change-event:

var

sCode = (xfa.event.newText) ? this.boundItem(xfa.event.newText) : this.rawValue;

if(sCode == "Opt1")
{
    Opt1ServicesRequired.presence = "visible";
    OtherServicesRequired.presence = "hidden";
}
else if(sCode == "Select...")
{
    Opt1ServicesRequired.presence = "hidden";
    OtherServicesRequired.presence = "hidden";
}
else
{
    Opt1ServicesRequired.presence = "visible";
    OtherServicesRequired.presence = "hidden";
}

Avatar

Former Community Member

Sadly, I get the exact same behaviour with that code as the original :-\

Also tried it in the layout:ready (both versions of the code) and get the same thing.

Avatar

Level 6

xfa.event.newText is the better approach also you could try xfa.layout.relayout(); at the end of the code. See if that makes any difference. If you still have issues I would like to review your template....send me email at "meetsekharv AT yahoo.com"

Avatar

Former Community Member

Well, after some random playing with stuff, it seems to have sorted itself

Im not sure, but I think the issue may be related to the Text item type... The original subforms just had a Text element in them for testing purposes. Putting some proper stuff in the forms was working, but when I added another Text element, the interactive elements like check boxes hide as expected, but the Text remains on screen until a 2nd change is made!

Anyway, managed to do what I was intending on doing now, so will consider this "answered" as no doubt something in it helped