Copy link to clipboard
Copied
I have a file with several calculations in - see attached file.
But one calculation works only partly - the field 'Intervalløn beregnet'.
The calculation-script is:
var q = getField("Aftalt timeløn").value;
var n = getField("Reguleringsprocent").value;
event.value = q*1924/n;
'Aftalt Timeløn' is a field that can be filled with a number, format is a number with two digits.
'Reguleringsprocent' is a field with a fixed numer, format number/no format, digit-seperater , or . (- none of these has made the soution for me)
The problem:
The file works fine in Adboe (at least at my pc)
The file works fine in browser (Chrome), as long as the number filled in has no digits.
The fault appears, if theres digits added in the number filled in - then the result just shows 'nan'
How can I get the field to work properly?
Copy link to clipboard
Copied
Assuming you use comma as decimal point and no thousand separator as format, you can convert comma to dot in your script like this:
var q = this.getField("Aftalt timeløn").valueAsString.replace(",", ".");
var n = this.getField("Reguleringsprocent").valueAsString.replace(",", ".");
q = Number(q);
n = Number(n);
Copy link to clipboard
Copied
Browsers may not have full support for scripts.
Copy link to clipboard
Copied
Maybe not.
But that doesn't explain why the script works without digtigs - but not with the digits.
And all the other scripts in the form works fine - including digits.
Copy link to clipboard
Copied
You will get NaN when n is zero.
Copy link to clipboard
Copied
But n is never zero.
n is a fixed number - the calculation works if q = 159, but not if q = 158,59, so it makes no sense to me.
Copy link to clipboard
Copied
Emter: 158.59
Copy link to clipboard
Copied
Ok - I can see that it'll do the trick.
But it's not me who shall put in the number - and here in Denmark no one use that format.
Is there a way to make it accept the 158,59?
all other calculations work fine with the comma.
Copy link to clipboard
Copied
Assuming you use comma as decimal point and no thousand separator as format, you can convert comma to dot in your script like this:
var q = this.getField("Aftalt timeløn").valueAsString.replace(",", ".");
var n = this.getField("Reguleringsprocent").valueAsString.replace(",", ".");
q = Number(q);
n = Number(n);
Copy link to clipboard
Copied
Thanks!
it works 😄