Easy way to make all fields visible when printed

Avatar

Avatar

nicolec26875103

Avatar

nicolec26875103

nicolec26875103

02-12-2018

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!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

radzmar

MVP

Avatar

radzmar

MVP

radzmar
MVP

03-12-2018

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.

Answers (0)