Copy link to clipboard
Copied
I have a checkbox that I want checked when the value is equal greater than 2500 and unchecked when below. Trying to run a validation script but I can't figure out why this isn't working.
if (event.value >= 2500)
{
this.getField("PriceBox").value != "Off"
} else {
this.getField("PriceBox").value == "Off"
}
Copy link to clipboard
Copied
Your code is nearly correct, assuming it's a validation script on the text field where the number value is entered.
the problem is that you are using comparison operators, instead of assignment operators.
Here's the fix.
if (event.value >= 2500)
{
this.getField("PriceBox").value = "Yes"
} else {
this.getField("PriceBox").value = "Off"
}
Copy link to clipboard
Copied
This will only work if the Export Value of the check-box is "Yes". To make it independent of that you can use this code:
this.getField("PriceBox").checkThisBox(0, (event.value >= 2500));
Copy link to clipboard
Copied
Try:
// this is a field level calculation script that
// goes in the AMOUNT FIELD
// Assumes PriceBox is a yes or no checkbox field
var amount = Number(this.getField("AMOUNT FIELD").value);
var checkbox = this.getField("PriceBox");
if (amount >= 2500) {
checkbox.checkThisBox(0, true); // Check the box
} else if (amount < 2500) {
checkbox.checkThisBox(0, false); // Uncheck the box
}
event.value = amount; // Optional, if the field should still show the value
Copy link to clipboard
Copied
Your code is nearly correct, assuming it's a validation script on the text field where the number value is entered.
the problem is that you are using comparison operators, instead of assignment operators.
Here's the fix.
if (event.value >= 2500)
{
this.getField("PriceBox").value = "Yes"
} else {
this.getField("PriceBox").value = "Off"
}
Copy link to clipboard
Copied
This will only work if the Export Value of the check-box is "Yes". To make it independent of that you can use this code:
this.getField("PriceBox").checkThisBox(0, (event.value >= 2500));
Copy link to clipboard
Copied
Thank you sir. What is the difference between comparison and assignment?
Copy link to clipboard
Copied
Comparison operators are for comparing two values. The operators include:
> Greater than
< Less than
== equals
!= Not Equal
The Assignment operator assigns a value to a varialbe
var a = 1 + 1;
Copy link to clipboard
Copied
Ah okay thank you sir.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now