• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Calculation won't work with digits when opened in browser

New Here ,
Jan 08, 2025 Jan 08, 2025

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? 

TOPICS
General troubleshooting

Views

183

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jan 08, 2025 Jan 08, 2025

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);

View solution in original post

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

Browsers may not have full support for scripts.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 08, 2025 Jan 08, 2025

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

You will get NaN when n is zero.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 08, 2025 Jan 08, 2025

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

Emter: 158.59

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 08, 2025 Jan 08, 2025

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 08, 2025 Jan 08, 2025

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 09, 2025 Jan 09, 2025

Copy link to clipboard

Copied

LATEST

Thanks! 

it works 😄 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines