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

Custom format script - percentage with 2 decimal places

New Here ,
Mar 09, 2022 Mar 09, 2022

What would I enter in the Custom Format Script field if I want a number to appear as a percentage with 2 decimal places? So, for example, if 8 is written in the field, it shows up as 8.00%. I found this:

 

if (event.value) event.value+="%"; 

 

which shows 8 as 8%, but what do I couple it with to show 8.00%? 

 

Thanks,

Sarah 

TOPICS
Create PDFs , Edit and convert PDFs , JavaScript , PDF forms
3.2K
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 09, 2022 Mar 09, 2022

Use this:

var x = Number(event.value);
if(event.value)
event.value = x.toFixed(2)+"%";

View solution in original post

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 ,
Mar 09, 2022 Mar 09, 2022

Use this:

var x = Number(event.value);
if(event.value)
event.value = x.toFixed(2)+"%";

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 ,
Mar 10, 2022 Mar 10, 2022

Works beautifully, thanks so much Nesa!! 

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 ,
Mar 21, 2023 Mar 21, 2023

I am trying to use this script but i can only get it to work in one cell or one place how can i change the script to use it in multiple places where i want to show inputed percentages

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 ,
Mar 21, 2023 Mar 21, 2023

It should work in different fields as long as you put in custom format script.

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 ,
Mar 21, 2023 Mar 21, 2023

Thank you so much! Works

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 16, 2025 May 16, 2025

The script works as expected if I only input values into the original scripted field.  However, there are many other unscripted fields, and when I put any value into them, I get a NaN% error in the original field.  Please help.  

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 16, 2025 May 16, 2025
LATEST

You need to explain what exactly you are trying to do and what script did you use, and where did you place it?

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