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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Easy way to make all fields visible when printed

nicolec26875103
Level 2
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
radzmar
Correct answer by
Level 10
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

1 Reply
radzmar
Correct answer by
Level 10
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