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

Convert text field number (range) to a word

New Here ,
May 07, 2019 May 07, 2019

I have set up a text field to properly calculate and display a number on a scale ranging from 1.00 to 4.00. Now, using a "Custom Format Script" in the FORMAT TAB, I would like the field to display the following text: BRONZE for values ranging from 1.00 to 2.39; SILVER for 2.40 to 3.39; GOLD for 3.40 to 4.00. Any suggestions?

TOPICS
Acrobat SDK and JavaScript
525
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

correct answers 1 Correct answer

Community Expert , May 07, 2019 May 07, 2019

Use this code:

if (event.value>1 && event.value<2.39) event.value = "BRONZE";

else if (event.value>=2.4 && event.value<3.39) event.value = "SILVER";

else if (event.value>=3.4 && event.value<=4) event.value = "GOLD";

Translate
Community Expert ,
May 07, 2019 May 07, 2019

Use this code:

if (event.value>1 && event.value<2.39) event.value = "BRONZE";

else if (event.value>=2.4 && event.value<3.39) event.value = "SILVER";

else if (event.value>=3.4 && event.value<=4) event.value = "GOLD";

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

Works great! I did end up changing the value of 1 in the first line to .5 because (since I was using averages), when 4 radio buttons that equal "1" were simultaneously selected it would display 1 instead of "Bronze," but as I said, changing the "1" in the first line to .5 solved that. -hope that makes sense. THANKS for your time!

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