Skip to main content
zacb85173355
Known Participant
September 20, 2016
Answered

Using password to hide/show fields? (instead of activating/deactivating)

  • September 20, 2016
  • 2 replies
  • 803 views
Back in 2010 George_Johnson posted the script below, it lets you activate/deactivate fields with a password.  I tried it and it worked perfectly.  But when I had one of my friends try my document out, he just clicking away at the deactivated fields (buttons) trying to make them work.  I realized what I really need to do is hide them instead of deactivating them.  I was thinking this script below could be modified to show/hide instead of activate/deactivate, but I don't know enough about java yet to do it.  I started to try but I think I don't know enough yet.  My buttons that I would like to show/hide are X, Y, and Z.  Thank you George and/or anyone who has an idea on this.

Zac B., Cypress CA

(function () {
    // Get one of the fields in the group    var f = getField("private.name");

    // Determine new readonly state, which    // is the opposite of the current state    var readonly = !f.readonly;

    var readonly_desc = readonly ? "deactivate" : "activate";

    // Ask user for password    var resp = app.response({        cQuestion: "To " + readonly_desc + " the fields, enter the password:",        cTitle: "Enter password",        bPassword: true,        cLabel: "Password"    });

    switch (resp) {

    case "your_password": // Your password goes here        getField("private").readonly = readonly;        app.alert("The fields are now " + readonly_desc + "d.", 3);        break;

    case null : // User pressed Cancel button        break;

    default : // Incorrect password        app.alert("Incorrect password.", 1);        break;}

})();

ReplySelect to enter your comment text

This topic has been closed for replies.
Correct answer George_Johnson

You can add the following line after the one that's similar:

getField("private").display = readonly ? display.hidden : display.visible; 

2 replies

zacb85173355
Known Participant
September 21, 2016

It works!!!!!  thank you so much!!!!!  --Zac

George_JohnsonCorrect answer
Inspiring
September 20, 2016

You can add the following line after the one that's similar:

getField("private").display = readonly ? display.hidden : display.visible;