Copy link to clipboard
Copied
I am trying to get my text field "Text 2" to populate based on the value in field "Text 1". If "Text 1" is less than 0.75, then "Text 2" should fill with "Not Met." Below is the custom calculation that I am setting up for "Text 2." Can someone tell me what I am doing wrong in my script?
var a=this.getField("Text 1").value;
var num1=0.75
var num2=1.75
var num3=2.75
if(var a<var num1){
event.value=a=="Not Met"?"":a;
}
Thank you!!
Copy link to clipboard
Copied
The "var" keyword should only be used once, to declare a variable for the first time. After that you only need to use the variable's name.
So change this line:
if(var a<var num1){
To:
if(a<num1){
Also, this line is incorrect:
event.value=a=="Not Met"?"":a;
Replace that entire section of the code with just this:
event.value= (a<num1) ? "Not Met" : "";
Copy link to clipboard
Copied
Thank you!! I made the changes and it was accepted but the field remains
blank. The value in "Text 1" is 0.25714 but "Text 2" is blank. Is it
because "Text 1" is a calculated field? Also, to finish out my script
would the below be correct?
var a=this.getField("Text 1").value;
var num1=0.75
var num2=1.75
var num3=2.75
if(a<num1){
event.value= (a<num1) ? "Not Met" : "";
}
else if(a<num2){
event.value= (a<num2) ? "Approaching" : "";
}
else if(a<num3){
event.value= (a<num3) ? "Solid Performance" : "";
}
else if(a>num){
event.value= (a>num3) ? "Exceeds Expectations" : "";
}
I really appreciate your help try67. I've done a lot of studying
Copy link to clipboard
Copied
If you're using multiple conditions you can't combine it with the tertiary comparison operator.
Instead, just to this:
if (a<num1) event.value = "Not Met";
else if (a<num2) event.value = "Approaching";
else if (a<num3) event.value = "Solid Performance";
else event.value = "Exceeds Expectations";
Copy link to clipboard
Copied
Thank you. I have tried the below in the Custom Calculation Script and
then in the Custom Format Script. For some reason "text 2" remains blank
even though there is a value in "text 1."
var a=this.getField("Text 1").value;
var num1=0.75
var num2=1.75
var num3=2.75
if (a<num1) event.value = "Not Met";
else if (a<num2) event.value = "Approaching";
else if (a<num3) event.value = "Solid Performance";
else event.value = "Exceeds Expectations";
Copy link to clipboard
Copied
- It's a Calculation script, not a Format script.
- Check the JS-Console (Ctrl+J) for error messages.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now