Avatar

Level 10

You have to set the presence property. For example,

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

form1.page1.subform1.name.presence = "visible";

If you have a form with a text field called 'name' and a button called 'visibilityBtn' with a caption of 'Hide', you could attach the following script to the click event of the button to toggle the visibility of the text field from visible to hidden.

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

var status = xfa.resolveNode("form1.page1.subform1.visibilityBtn.caption.value.#text").value;

if (status == "Hide") {

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

  xfa.resolveNode("form1.page1.subform1.visibilityBtn.caption.value.#text").value = "Show";

}

else {

  form1.page1.subform1.name.presence = "visible";

  xfa.resolveNode("form1.page1.subform1.visibilityBtn.caption.value.#text").value = "Hide";

}

Note - the most common mistake when it comes to dynamic form behaviour is to forget to save the form as a dynamic PDF form.

Steve