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

Easy way to make all fields visible when printed

Avatar

Level 2

Good morning!

I have a form which requires some questions to be answered depending on the previous answer.  If it is not needed, the next question stays hidden.  BUT then we realised, if someone decides to print out the form to then fill it out, unfortunately the hidden fields obviously do not print.  I have been using the PrePrint event and using the code

this.presence = "visible";

into each field.

I was just wondering if there was an easier or a bulk way to set "all" Hidden fields to visible IF the form is printed?

Many thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

a very simple way is a recursive function like this one. It finds all fields in the form that aren't visible and changes them to be visible:

function changeFields (oNode) { 

    if (oNode.className === "field") { 

        if (oNode.presence !== "visible") { 

            oNode.presence = "visible"

        } 

    } 

    for (var i = 0; i < oNode.nodes.length; i += 1) { 

        changeFields(oNode.nodes.item(i)); 

    } 

}

changeFields(xfa.form); // call the function

The real challenge will be to find out, which fields to hide again after printing the form.

View solution in original post

0 Replies

Avatar

Correct answer by
Level 10

Hi,

a very simple way is a recursive function like this one. It finds all fields in the form that aren't visible and changes them to be visible:

function changeFields (oNode) { 

    if (oNode.className === "field") { 

        if (oNode.presence !== "visible") { 

            oNode.presence = "visible"

        } 

    } 

    for (var i = 0; i < oNode.nodes.length; i += 1) { 

        changeFields(oNode.nodes.item(i)); 

    } 

}

changeFields(xfa.form); // call the function

The real challenge will be to find out, which fields to hide again after printing the form.