Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Custom Calculation Javascript

New Here ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

Hello, I apolgize if this isn't the write place to request this, but was hoping could get help with a custom calculation script. I see similar calculation script posts but not too good with code to change to this specficiation. 

 

I would like to set the field to "Number" format category (no decimals, just initally), but when they enter the number it calculates this way:

  • Make the formula divide the number entered by 10,000, (e.g. so value 40 entered gets displayed as “0.0040”)

 

Thank you for any help in advance

TOPICS
How to, JavaScript, PDF forms

Views

457

Likes

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

correct answers 1 Correct answer

Adobe Community Professional , Jun 22, 2021 Jun 22, 2021
In that case you can't use the Number format. Check it to Custom and as the custom Format script enter the following: if (event.value) event.value = event.value/10000;

Likes

Translate

Translate
Adobe Community Professional ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

Do you want to actually change the value they enter, or just display it in this way?

Likes

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 ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

The value can remain the same, I just want it to be displayed as the decimal/calculation. 

Likes

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
Adobe Community Professional ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

In that case you can't use the Number format. Check it to Custom and as the custom Format script enter the following:

 

if (event.value) event.value = event.value/10000;

Likes

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 ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

This is great, thank you very much. Is there anyway to include in the code an option to restict the value to number format? 

 

Either way this is very helpful and works as intended. 

 

Thank you again for your time and help!

Likes

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
Adobe Community Professional ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

LATEST

You would need to use a custom keystroke or validation script for that.

For the latter you can use something simple, like this:

 

if (isNaN(Number(event.value))) {

event.rc = false;

app.alert("You must enter a number.");

}

Likes

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