Skip to main content
Participant
May 7, 2019
Answered

Convert text field number (range) to a word

  • May 7, 2019
  • 2 replies
  • 529 views

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?

This topic has been closed for replies.
Correct answer try67

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

2 replies

band4meAuthor
Participant
May 7, 2019

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!

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 7, 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";