Convert text field number (range) to a word

May 07, 2019

Copy link to clipboard

Copied

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?

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";

TOPICS
Acrobat SDK and JavaScript

Views

73

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

Convert text field number (range) to a word

May 07, 2019

Copy link to clipboard

Copied

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?

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";

TOPICS
Acrobat SDK and JavaScript

Views

74

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

Copy link to clipboard

Copied

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";

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
Reply
Loading...
May 07, 2019 1
band4me LATEST
May 07, 2019

Copy link to clipboard

Copied

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!

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
Reply
Loading...
May 07, 2019 0