• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How do I show multiple fields based on the value of another field in conjunction with the visibility of others?

Engaged ,
May 06, 2016 May 06, 2016

Copy link to clipboard

Copied

I have 17 text fields "issues" and have hidden buttons for each that I would like to appear once an admin puts in a "password" at the footer of the page.

For the "password" I've created a text field to enter such password and a button to "Log In."

What I'd like to be able to do is for the user to put in the "password" and the "Log In" button contains the script needed to show these fields. The 17 text fields only show one at a time, so I want the action of the "Log In" button to only show the hidden buttons corresponding to the current visible fields.

Below is my code. What happens is no matter what I do, it says the password is incorrect and hides "issue1" which is never specified in the code other than in a variable.

I originally had the first "else if" statement as the first "if" statement, but the results are the same either way.

var res = this.getField("resolution");
var password = this.getField("password");
var res1 = this.getField("add-res1");
var res2 = this.getField("add-res2");
var res3 = this.getField("add-res3");
var res4 = this.getField("add-res4");
var res5 = this.getField("add-res5");
var res6 = this.getField("add-res6");
var res7 = this.getField("add-res7");
var res8 = this.getField("add-res8");
var res9 = this.getField("add-res9");
var res10 = this.getField("add-res10");
var res11 = this.getField("add-res11");
var res12 = this.getField("add-res12");
var res13 = this.getField("add-res13");
var res14 = this.getField("add-res14");
var res15 = this.getField("add-res15");
var res16 = this.getField("add-res16");
var res17 = this.getField("add-res17");
var issue1 = this.getField("issue1");
var issue2 = this.getField("issue2");
var issue3 = this.getField("issue3");
var issue4 = this.getField("issue4");
var issue5 = this.getField("issue5");
var issue6 = this.getField("issue6");
var issue7 = this.getField("issue7");
var issue8 = this.getField("issue8");
var issue9 = this.getField("issue9");
var issue10 = this.getField("issue10");
var issue11 = this.getField("issue11");
var issue12 = this.getField("issue12");
var issue13 = this.getField("issue13");
var issue14 = this.getField("issue14");
var issue15 = this.getField("issue15");
var issue16 = this.getField("issue16");
var issue17 = this.getField("issue17");
var iv1 = issue1.display = display.visible;
var iv2 = issue2.display = display.visible;
var iv3 = issue3.display = display.visible;
var iv4 = issue4.display = display.visible;
var iv5 = issue5.display = display.visible;
var iv6 = issue6.display = display.visible;
var iv7 = issue7.display = display.visible;
var iv8 = issue8.display = display.visible;
var iv9 = issue9.display = display.visible;
var iv10 = issue10.display = display.visible;
var iv11 = issue11.display = display.visible;
var iv12 = issue12.display = display.visible;
var iv13 = issue13.display = display.visible;
var iv14 = issue14.display = display.visible;
var iv15 = issue15.display = display.visible;
var iv16 = issue16.display = display.visible;
var iv17 = issue17.display = display.visible;
var ih1 = issue1.display = display.hidden;
var ih2 = issue2.display = display.hidden;
var ih3 = issue3.display = display.hidden;
var ih4 = issue4.display = display.hidden;
var ih5 = issue5.display = display.hidden;
var ih6 = issue6.display = display.hidden;
var ih7 = issue7.display = display.hidden;
var ih8 = issue8.display = display.hidden;
var ih9 = issue9.display = display.hidden;
var ih10 = issue10.display = display.hidden;
var ih11 = issue11.display = display.hidden;
var ih12 = issue12.display = display.hidden;
var ih13 = issue13.display = display.hidden;
var ih14 = issue14.display = display.hidden;
var ih15 = issue15.display = display.hidden;
var ih16 = issue16.display = display.hidden;
var ih17 = issue17.display = display.hidden;

if(password.value == "") {
    res.display = display.hidden;
    res1.display = display.hidden;
res2.display = display.hidden;
res3.display = display.hidden;
res4.display = display.hidden;
res5.display = display.hidden;
res6.display = display.hidden;
res7.display = display.hidden;
res8.display = display.hidden;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;
}

else if(password.value == "firefly" && iv1 && ih2 && ih3 && ih4 && ih5 && ih6 && ih7 && ih8 && ih9 && ih10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.hidden;
res3.display = display.hidden;
res4.display = display.hidden;
res5.display = display.hidden;
res6.display = display.hidden;
res7.display = display.hidden;
res8.display = display.hidden;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && ih3 && ih4 && ih5 && ih6 && ih7 && ih8 && ih9 && ih10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.hidden;
res4.display = display.hidden;
res5.display = display.hidden;
res6.display = display.hidden;
res7.display = display.hidden;
res8.display = display.hidden;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && ih4 && ih5 && ih6 && ih7 && ih8 && ih9 && ih10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.hidden;
res5.display = display.hidden;
res6.display = display.hidden;
res7.display = display.hidden;
res8.display = display.hidden;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && ih5 && ih6 && ih7 && ih8 && ih9 && ih10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.hidden;
res6.display = display.hidden;
res7.display = display.hidden;
res8.display = display.hidden;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && ih6 && ih7 && ih8 && ih9 && ih10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.hidden;
res7.display = display.hidden;
res8.display = display.hidden;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && ih7 && ih8 && ih9 && ih10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.hidden;
res8.display = display.hidden;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && ih8 && ih9 && ih10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.hidden;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && ih9 && ih10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && iv9 && ih10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.noPrint;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && iv9 && iv10 && ih11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.noPrint;
res10.display = display.noPrint;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && iv9 && iv10 && iv11 && ih12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.noPrint;
res10.display = display.noPrint;
res11.display = display.noPrint;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && iv9 && iv10 && iv11 && iv12 && ih13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.noPrint;
res10.display = display.noPrint;
res11.display = display.noPrint;
res12.display = display.noPrint;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && iv9 && iv10 && iv11 && iv12 && iv13 && ih14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.noPrint;
res10.display = display.noPrint;
res11.display = display.noPrint;
res12.display = display.noPrint;
res13.display = display.noPrint;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && iv9 && iv10 && iv11 && iv12 && iv13 && iv14 && ih15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.noPrint;
res10.display = display.noPrint;
res11.display = display.noPrint;
res12.display = display.noPrint;
res13.display = display.noPrint;
res14.display = display.noPrint;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && iv9 && iv10 && iv11 && iv12 && iv13 && iv14 && iv15 && ih16 && ih17) {
    res.display = display.visible;
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.noPrint;
res10.display = display.noPrint;
res11.display = display.noPrint;
res12.display = display.noPrint;
res13.display = display.noPrint;
res14.display = display.noPrint;
res15.display = display.noPrint;
res16.display = display.hidden;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && iv9 && iv10 && iv11 && iv12 && iv13 && iv14 && iv15 && iv16 && ih17) {
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.noPrint;
res10.display = display.noPrint;
res11.display = display.noPrint;
res12.display = display.noPrint;
res13.display = display.noPrint;
res14.display = display.noPrint;
res15.display = display.noPrint;
res16.display = display.noPrint;
res17.display = display.hidden;

}

else if(password.value == "firefly" && iv1 && iv2 && iv3 && iv4 && iv5 && iv6 && iv7 && iv8 && iv9 && iv10 && iv11 && iv12 && iv13 && iv14 && iv15 && iv16 && iv17) {
    res1.display = display.noPrint;
res2.display = display.noPrint;
res3.display = display.noPrint;
res4.display = display.noPrint;
res5.display = display.noPrint;
res6.display = display.noPrint;
res7.display = display.noPrint;
res8.display = display.noPrint;
res9.display = display.noPrint;
res10.display = display.noPrint;
res11.display = display.noPrint;
res12.display = display.noPrint;
res13.display = display.noPrint;
res14.display = display.noPrint;
res15.display = display.noPrint;
res16.display = display.noPrint;
res17.display = display.noPrint;

}

else {
    app.alert("The wrong password was entered. Please enter the correct password.")
    iv1;
    res1.display = display.hidden;
res2.display = display.hidden;
res3.display = display.hidden;
res4.display = display.hidden;
res5.display = display.hidden;
res6.display = display.hidden;
res7.display = display.hidden;
res8.display = display.hidden;
res9.display = display.hidden;
res10.display = display.hidden;
res11.display = display.hidden;
res12.display = display.hidden;
res13.display = display.hidden;
res14.display = display.hidden;
res15.display = display.hidden;
res16.display = display.hidden;
res17.display = display.hidden;
}

TOPICS
Acrobat SDK and JavaScript

Views

766

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 06, 2016 May 06, 2016

These lines in your code don't make sense (and the rest of the code is dependent on them):

var iv1 = issue1.display = display.visible;

I think what you probably mean to do is this:

var iv1 = (issue1.display == display.visible);

This sentence of yours indicates a lack of understanding of the JS operators:

I've also tried several equal sign operators for password.value including a single equal sign through three equal signs.

You should do some research and find out what the differences are between "="

...

Votes

Translate

Translate
Advocate ,
May 06, 2016 May 06, 2016

Copy link to clipboard

Copied

Do you get any error messages in the Console?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 06, 2016 May 06, 2016

Copy link to clipboard

Copied

Not that I'm aware of. Debugger typically tells me if there's a syntax error immediately, not to mention when I click the button. I'm not experiencing any of that.

I've also tried several equal sign operators for password.value including a single equal sign through three equal signs. All three give me the same results.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2016 May 06, 2016

Copy link to clipboard

Copied

LATEST

These lines in your code don't make sense (and the rest of the code is dependent on them):

var iv1 = issue1.display = display.visible;

I think what you probably mean to do is this:

var iv1 = (issue1.display == display.visible);

This sentence of yours indicates a lack of understanding of the JS operators:

I've also tried several equal sign operators for password.value including a single equal sign through three equal signs.

You should do some research and find out what the differences are between "=", "==" and "==='. They are crucial for your code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines