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

Always Rounding Down a Calculated Value & Not Re-Calculating

New Here ,
May 13, 2019 May 13, 2019

Good Morning All,

I am in the process of creating a PDF form that i require a value to be calculated when the value is modified in a different field.  I have been searching around the forum and i have found the following post Help with rounding writing a function for rounding down. .

I have modified the code to that shown below to fit my situation and fields.

var result = (Number(this.getField("ModuleWidth").value-12)/180;

event.value = Math.floor(Math.abs(result));

This is calculating the value correctly however is isn't carrying out the rounding and then only displaying the rounded result to one whole number.

Basically i am wanting to display the whole number of the calculated value regardless of whether or not its 4.99 or 4.01 so it always rounds down to a whole number.

Also currently if i change the value of the figure in the driving the field the calculating value doesn't seem to be updating at all.

I look forward to hearing from you soon.


Thanks in advanced

Frosty

TOPICS
PDF forms
707
Translate
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 ,
May 13, 2019 May 13, 2019

Try this:

var result = (Number(this.getField("ModuleWidth").valueAsString)-12)/180;

event.value = Math.floor(Math.abs(result));

Translate
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 ,
May 13, 2019 May 13, 2019

Hi Bernd,


Thanks for your reply.  I have tried putting this in the custom calculation script property of the text field however the field doesn't seem to calculate.  There are no syntax errors being displayed for the script but when i change the value of the ModuleWidth field nothing displays in the field.

As such i don't know whether or not this has resolved the issue.  Any ideas?

Frosty

Translate
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 ,
May 13, 2019 May 13, 2019

Check the field calculation order.

Translate
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 ,
May 13, 2019 May 13, 2019

how does the calculation order work as i currently have it at the bottom as that's the last thing i want to calculate after something has changed but obviously that is incorrect

Translate
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 ,
May 13, 2019 May 13, 2019
LATEST

Post a screenshot of the field calculation order.

Translate
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