Copy link to clipboard
Copied
I'm trying to figure out what the format would be for the following calculation
I'm taking the number in text1.0.1 multiplied by 150 and getting the pardons in field text 2 as a 4 digit number
i need to take the number in text1.0.1 25,950,075.0 x 150 = 3,893,711,250
now i only need the first 4 numbers in the answer 3893 to post in text2 the 1st box under pardons.
here is the calculation box -
which box do I use and what is the javascript that I put in the edit box when I open it.
once I get the correct format, I can just copy that format down to the other pardon fields and change the first field box and all else should work
all help would be great appreciated
Ms Linda
Copy link to clipboard
Copied
Use 'Custom calculation script' box of "Text2" field, and put this inside:
var num = Number(this.getField("Text1.0.1").valueAsString)*150;
var str = num.toString().slice(0,4);
if(str.length == 4)
event.value = str;
else
event.value = "";
Copy link to clipboard
Copied
Thank you so very much and with that calculation script, i was able to complete the form for 7 fields just by changing the text box number it was completed in a matter of minutes and all the numbers worked perfectly.
thank you again for your assistance
Ms Linda
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Post script you used for lower numbers.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Use this:
var f = this.getField("Text1.1.1").valueAsString;
var num = Number(f)*150;
var str = num.toString();
if(f.length >= 8)
event.value = str.slice(0,4);
else if(f.length == 7)
event.value = str.slice(0,3);
else if(f.length == 6)
event.value = str.slice(0,2);
else if(f == "")
event.value = "";
It will work for all fields with values between 100,000-999,999 2 digits, 1,000,000-9,999,999 3 digits,10,000,000 and above 4 digits, you can easily adapt it( e.g. number less than 100,000) if needed.
When using in other fields just change field name in script.