I don't quite understand what the issue is... Just set the Total field's format to the format you want to use.
Also, if the code above is used as the Total field's custom calculation script then change the last line to:
event.value = total;
The point is that my input multiline field does not seem to sum the number. I paste the information like this:
The total field does not seem to calculate even if I use event.value.
I guess the calculations are ran in a different format. If each of the numbers were in specific fields, it would just be a matter of formatting the fields and using event.value = total;, but I may be missing something here...
Thanks for your usual and kind help.
It's quite difficult to know what is going on without seeing the actual
file. Can you share it?
Just sent the file to your e-mail, many thanks for the help!
Under what action did you place this script?
The solution was to add another line of code to remove the periods used as thousands separators in the numbers.
Make sure the "." is removed before replacing the ",".
A possible solution:
var withcoma = this.getField("Input_1").value + "\r"; //this is my multiline field used to paste data from excel
nocoma = withcoma.replace(/\./g,""); // remove ".";
nocoma = nocoma.replace(/\,/g,"."); // replace "," with "."
var values = nocoma.split("\r"); // make nocoma into an array;
// crate JS statement from array or values to compute the sum and evaluate the statement;
event.value = eval("+1*" + values.join("+1*")+"0");
Many thanks for the reply, I will definitely take a look at your code! Gilad has helped me as usual, but I will try your approach as well, as it may be useful for future projects!
It's exactly the same solution as I created for you...