Copy link to clipboard
Copied
Hi all. I'm relatively new to the whole JavaScript in Adobe Acrobat thing so I'll try to be as concise as possible.
Simply put, I have created a dropdown menu named "Banklist" with 2 options "Bank 1" and "Bank 2".
I used the following Validation script and everything works as I had hoped:
if(event.value =="Bank 1"){
this.getField("MCCCODE").display = display.visible;
this.getField("Test1").display = display.visible;
}
else{
this.getField("MCCCODE").display=display.hidden;
this.getField("Test1").display=display.hidden;
}
if(event.value =="Bank 2"){
this.getField("Text5test").display = display.visible;
}
else{
this.getField("Text5test").display=display.hidden;
}
My problem is that if I click on a dropdown in an unrelated area of the form (named Combo Box01 for example), as soon as I select an option it automatically causes "Bank 1" to appear and the second hidden box appears as well. Does anyone have any ideas as to what is causing unrelated dropdowns to affect each other?
I'm sure I'm missing something simple but for the life of me I can not think of what it is.
Thank you in advance for all your help. This is driving me crazy!
You've made a classic mistake that many people do. You've used the value assignment operator ( = ) in your if-condition instead of the value comparison operator ( == ). Change it in both statements and it should solve the issue.
Also, you used the wrong method names. It's getField, not getfield, and setItems, not setitems. Remember that JavaScript is case-sensitive! However, that first line doesn't really do anything, really, so you should remove it entirely.
Copy link to clipboard
Copied
Do you have any calculation script somewhere in your file that sets the options of this drop-down field, or reset the form, or something like that?
Copy link to clipboard
Copied
I have the following Calculation scripts but they are both in fields that would be populated by selecting an option from the dropdowns. No other calculation scripts anywhere in the file.
var v = this.getField("MCCCODE").value;
if (v=="5962") event.value = "0.100%";
else if (v=="5966") event.value = "0.100%";
else if (v=="7995") event.value = "0.100%";
else if (v=="4813") event.value = "0.100%";
else if (v=="7273") event.value = "0.100%";
else if (v=="5967") event.value = "0.350%";
else if (v=="1750") event.value = "0.010%";
else if (v=="3000-3298") event.value = "0.010%";
else if (v=="4511") event.value = "0.010%";
else if (v=="4112") event.value = "0.010%";
else if (v=="4131") event.value = "0.010%";
else if (v=="4411") event.value = "0.010%";
else if (v=="4722") event.value = "0.010%";
else if (v=="5712") event.value = "0.010%";
else if (v=="5734") event.value = "0.010%";
else if (v=="5963") event.value = "0.010%";
else if (v=="5964") event.value = "0.010%";
else if (v=="5968") event.value = "0.010%";
else if (v=="5969") event.value = "0.010%";
else if (v=="6051") event.value = "0.010%";
else if (v=="7012") event.value = "0.010%";
else if (v=="7297") event.value = "0.010%";
else if (v=="7922") event.value = "0.010%";
else if (v=="Exceptions") event.value = "0.025%";
else event.value="";
and:
if (this.getField("Banklist").value = "Bank1"){
this.getfield("Banklist")
}
else if (this.getField("Banklist").value = "Bank2"){
this.getField("Text5test").setitems(["","0.50%"])
}
I'm sure there is a better way to write the first script but it works at least for the time being at least.
Copy link to clipboard
Copied
You've made a classic mistake that many people do. You've used the value assignment operator ( = ) in your if-condition instead of the value comparison operator ( == ). Change it in both statements and it should solve the issue.
Also, you used the wrong method names. It's getField, not getfield, and setItems, not setitems. Remember that JavaScript is case-sensitive! However, that first line doesn't really do anything, really, so you should remove it entirely.
Copy link to clipboard
Copied
You are my hero and most deserving of the MVP designation! That totally fixed the issue.
Thank you so much for the help. It was driving me insane! I don't think I'll forget about == vs = and case sensitivity in the future.
Thank you again!