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
Solved! Go to Solution.
Views
Replies
Total Likes
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'.
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
Views
Replies
Total Likes
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'.
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
Views
Replies
Total Likes
Thanks. I'll give this a try.
MDawn
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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?
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Views
Likes
Replies