Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Suppress blank AddressLine2 from printing

Avatar

Level 7

I'm trying the create a form that includes name and address. I'd like to include two address lines plus the City State ZIP. If AddressLine2 is blank, I'd like to avoid printing it and have the City State ZIP line move up and print in it's place.

Can anyone help me with this. I found a posting from 2008, but it didn't seem complete to this newbie.

Thanks,

MDawn

1 Accepted Solution

Avatar

Correct answer by
Level 10

It can be achieved using two sub-forms, one with 2 address lines and the other with 1 address line. You can see in the image, below, the two sub-forms are defined in the hierarchy view but 'subform2' is not visible. It has the same x and y coordinates and dimensions as 'subform1'.

foo.PNG

For demonstration purposes I added a print button and the following JavaScript on the print button click event:

// form1.page1.printBtn::click - (JavaScript, client)

if (form1.page1.subform1.address2.isNull || form1.page1.subform1.address2.rawValue == "") {

  form1.page1.subform2.name.rawValue = form1.page1.subform1.name.rawValue;

  form1.page1.subform2.address1.rawValue = form1.page1.subform1.address1.rawValue;

  form1.page1.subform2.city.rawValue = form1.page1.subform1.city.rawValue;

  form1.page1.subform2.state.rawValue = form1.page1.subform1.state.rawValue;

  form1.page1.subform2.zipCode.rawValue = form1.page1.subform1.zipCode.rawValue;

  form1.page1.subform1.presence = "hidden";

  form1.page1.subform2.presence = "visible";

}

xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);

The script checks for data in 'form1.page1.subform1.address2'. If there is no data, 'subform2' is populated from the applicable 'subform1' fields, 'subform1' is hidden, and 'subform2' is made visible.

The sample is attached.

Steve

View solution in original post

0 Replies

Avatar

Correct answer by
Level 10

It can be achieved using two sub-forms, one with 2 address lines and the other with 1 address line. You can see in the image, below, the two sub-forms are defined in the hierarchy view but 'subform2' is not visible. It has the same x and y coordinates and dimensions as 'subform1'.

foo.PNG

For demonstration purposes I added a print button and the following JavaScript on the print button click event:

// form1.page1.printBtn::click - (JavaScript, client)

if (form1.page1.subform1.address2.isNull || form1.page1.subform1.address2.rawValue == "") {

  form1.page1.subform2.name.rawValue = form1.page1.subform1.name.rawValue;

  form1.page1.subform2.address1.rawValue = form1.page1.subform1.address1.rawValue;

  form1.page1.subform2.city.rawValue = form1.page1.subform1.city.rawValue;

  form1.page1.subform2.state.rawValue = form1.page1.subform1.state.rawValue;

  form1.page1.subform2.zipCode.rawValue = form1.page1.subform1.zipCode.rawValue;

  form1.page1.subform1.presence = "hidden";

  form1.page1.subform2.presence = "visible";

}

xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);

The script checks for data in 'form1.page1.subform1.address2'. If there is no data, 'subform2' is populated from the applicable 'subform1' fields, 'subform1' is hidden, and 'subform2' is made visible.

The sample is attached.

Steve

Avatar

Level 7

I tried the script and am not having much success. The first time  I tried it, address line 2 was not suppressed. Also, I have script in the prePrint and postPrint on text fields to suppress printing the underlining and that wasn't working.

I reworked the form to change the subform and field naming to match the script, thinking maybe I had edited wrong. Now it won't print at all.

I've attached my form. I appreciate any help you can give me.

Thanks,

MDawn

Avatar

Level 10

There are a number of issues, including the JavaScript field references I used in my example don't match your form. Additionally, could you explain what you are trying to accomplish in the pre-print and post-print events?

Avatar

Level 7

I have underlining of certain text fields so the user know it's a field.

The prePrint and postPrint are to suppress the underlining in the field

from printing and then to put the underline back after printing.

Concerning the field references. I thought I had changed them to match

and still use the fields in my design.

Any help is much appreciated.

Thanks,

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I've been trying this some more. I can replicate your form in my own project, starting from a blank form. And it works fine. If I add any more subforms, then the Print Form button doesn't work. Am I missing something about the scripting? I'll attach my experimentation form.

Thanks,

MDawn