Skip to main content
Participating Frequently
April 19, 2022
Question

javascript calculations x 150 =

  • April 19, 2022
  • 1 reply
  • 712 views

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

 

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
April 19, 2022

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 = "";

Participating Frequently
April 19, 2022

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