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

Having trouble with the Math.floor command

Community Beginner ,
Apr 21, 2019 Apr 21, 2019

Copy link to clipboard

Copied

Hi all,

I know I am missing something, but can't quite figure out what. I am just trying to round a field down using the math.floor command I am certain I have the syntax wrong somewhere. Here is the script the calculation is working perfectly, but it is always rounding up.

event.value = ( this.getField("resourcesRow1").value *  this.getField("g1p1multiple1").value )*.5;

event.value = math.floor("g1p1resourcestotal");

Thanks for any help.

Regards,

Larry

TOPICS
Acrobat SDK and JavaScript

Views

1.0K

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 ,
Apr 21, 2019 Apr 21, 2019

Copy link to clipboard

Copied

Check the console for errors.

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 ,
Apr 21, 2019 Apr 21, 2019

Copy link to clipboard

Copied

It's Math.floor(), not math.floor()... It's important to remember that JS is case-sensitive.

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 ,
Apr 21, 2019 Apr 21, 2019

Copy link to clipboard

Copied

Also, the input parameter for that method needs to be a number, not a string.

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 ,
Apr 21, 2019 Apr 21, 2019

Copy link to clipboard

Copied

Use this:

event.value = Math.floor(Number(this.getField("resourcesRow1").valueAsString) * Number(this.getField("g1p1multiple1").valueAsString) * 0.5);

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 Beginner ,
Apr 21, 2019 Apr 21, 2019

Copy link to clipboard

Copied

LATEST

Thank you all for your input. The rewrite that try67 gave me worked. Now I am going to sit down and try to make sure I understand everything about it so I will be able to use it in the future.

Thanks for all the great input. You have all been a tremendous help to me.

Regards,

Larry

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