Copy link to clipboard
Copied
I'm still learning and I have messed this up.
I have a field labeled "numofmonths". I am trying to create a javascript that says if "numofmonths" is = 2, the value of the "results" field is 5% but if the "numofmonths" is greater than or equal to 3 the "result" field is 10%
Can someone help me?
Copy link to clipboard
Copied
Use this as custom calculation script of 'result' field:
var n = Number(this.getField("numofmonths").valueAsString);
if(n === 2)
event.value = n*0.05;
else if(n > 2)
event.value = n*0.1;
else
event.value = "";
Copy link to clipboard
Copied
Percentage of what value?
Copy link to clipboard
Copied
The value of the "numofmonnths" field
Copy link to clipboard
Copied
What it is less than 2? What if it is greater than 2 and less than 3?
Copy link to clipboard
Copied
I see what you mean, I made it. Confusing...
The "numofmonths" counts the number of months.
if the "numofmonths" is less than 2 then the "result " field = 0
if the "nunofmonths" equals 2 then the "result" field = 5%
if the "numofmonths" is greater than 2 the "result" field = 10%
I hope that makes sense.. can you help me figure it out?
Copy link to clipboard
Copied
If this explanation is the last one, try using the script I posted, it should do what you're asking for.
Copy link to clipboard
Copied
Use this as custom calculation script of 'result' field:
var n = Number(this.getField("numofmonths").valueAsString);
if(n === 2)
event.value = n*0.05;
else if(n > 2)
event.value = n*0.1;
else
event.value = "";