Skip to main content
Jymnazium
Participating Frequently
August 1, 2017
Answered

Displaying Field Based on Value Range

  • August 1, 2017
  • 1 reply
  • 1134 views

In my form, I'm trying to display a text box based on the value entered in another field (labeled Rating) falling into the range of 3.5 to 5.0. I've done a lot of research and everything I found says that the jscript code below should do what I want, but clearly I'm missing something as it has no effect. Note, I'm putting this as a custom calculation script in the box I want to show/hide.

---------------------------

if ((this.getField("Rating").value > "3.5") || (this.getField("Rating").value < "5")){

event.target.display = display.visible;

}

else{

event.target.display = display.hidden;

}

--------------------------

Anyone have any idea what I might be doing wrong?

Jim

This topic has been closed for replies.
Correct answer try67

Your condition doesn't make sense... Any number is either bigger than 3.5 or smaller than 5. Maybe you mean bigger then 3.5 AND smaller then 5? If so, replace "||" with "&&" in your code (without the quotes).

1 reply

Inspiring
August 1, 2017

Change that first line to the following:

if ((this.getField("Rating").value > 3.5) || (this.getField("Rating").value < 5)){

So that the comparison is using numerical values, not strings.

Jymnazium
JymnaziumAuthor
Participating Frequently
August 1, 2017

Dangit, I posted the one with quotes...

My last try was as you suggested (below) and it also seems to do nothing.. I can set "Rating" field to 2, 3, 6, etc.. and the field always shows.

--------------------

if ((this.getField("Rating").value > 3.5) || (this.getField("Rating").value < 5)){

event.target.display = display.visible;

}

else{

event.target.display = display.hidden;

}

-------------------------------

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 1, 2017

Your condition doesn't make sense... Any number is either bigger than 3.5 or smaller than 5. Maybe you mean bigger then 3.5 AND smaller then 5? If so, replace "||" with "&&" in your code (without the quotes).