Expand my Community achievements bar.

SOLVED

How to hide a field based on the value of a field in a different subform - null check doesn't work!

Avatar

Former Community Member

I'm using Javascript to set the actions. I need to hide a text field if the value of a field in another sub-form is null.

- tried checking the value of the other field for null - doesn't work

- tried setting a variable str2 where I know the value of the other field is available then checking that variable when I initialize the text field - doesn't work

What am I missing?

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi.

Try this in the originating sub form referring to the text field (X). 

if (this.rawValue = 1)

     {

          X.presence = "visible";

     }

else if (this.rawValue = null)

     {

          X.presence = "hidden";

     }

View solution in original post

3 Replies

Avatar

Level 10

Hi,

It depends, seems like there might be an error in your coding. Maybe an error in a Reference_Syntax or something like that...

Could you provide an image of your hierarchy + your snippet code so it will be easier to help you!

Avatar

Correct answer by
Level 2

Hi.

Try this in the originating sub form referring to the text field (X). 

if (this.rawValue = 1)

     {

          X.presence = "visible";

     }

else if (this.rawValue = null)

     {

          X.presence = "hidden";

     }

Avatar

Former Community Member

Thanks for the suggestion! I did end up using similar code and it worked once I had set the variable correctly. Learned about a new function that allowed the field value to be set - it was not being set properly on the change event.

fieldname.rawValue = xfa.event.newText