cancel
Showing results for 
Search instead for 
Did you mean: 

Hide subform based upon value in text field.

Former Member
0 Kudos

Hi,

My challenge is to not display (print) a subform when the value of one of the text fields in the subform is blank.

The body page of my form has a main subform --> Item_data_1.

This subform displays portions of the order record in columns. For example:

Qty Unit Weight Material# Material Descrip, then a couple of place holder text fields.

Within the subform Item_data_1, I have another subform --> CustMaterialNumber

To keep data in columns, this subform has 3 place holder fields, then a field for KDMAT, then some place holder fields.

This allows KDMAT directly below Material#.

I then have additional subform below the above, each with text fields bound to a record field.

The subforms are FLOWED / Western Text.

The following code does hide the field(s) if applied to each object in the subform.

if ( $.isNull ) then $.presence="hidden" else $.presence="visible" endif

But, if I do that, when KDMAT has a value, the field shifts to the left - which makes sense.

I think I need to apply code to the subform that checks the value of KDMAT, but not sure how or the correct syntax.

Thank you,

Accepted Solutions (0)

Answers (2)

Answers (2)

OttoGold
Active Contributor
0 Kudos

Please try to search before asking a basic question the next time. This questions was answered like zillion times here.

Regards Otto

Former Member
0 Kudos

Hi Patrick,

Do the scripting at the subform level i.e. the subform that contains the text field whose value determines the presence of the parent subform.

if (this.<textfieldname>.rawvalue == " ")

{

this.presence = "hidden";

}

I am more used to Javascript....

Hope that resolves your questions.

Regards,

Arun.

jitendra_mehta
Participant
0 Kudos

Hi Patrick:

Your solution worked when I refer to the text field in thr read:form event in the subform.

My question is I have several text field items under subform End_of_page. I don't want to check the value of each text fiela d in the subform. Can I write a script at subform level to hide all the text fields under the subform?

Jitendra Mehta

OttoGold
Active Contributor
0 Kudos

Of course you can place a script on subform, hide subform and not field by field. It is highly recommended and will have much better performance. You can even use relative addressing like this.presence = "hidden"; (when you place it on subform, this means the subform and thus will hide the subform for you).

Regards Otto