Copy link to clipboard
Copied
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
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).
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
}
-------------------------------
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
Thanks Try67! You were correct, using the "OR" logic instead of "AND" made it work perfectly....
Copy link to clipboard
Copied
The other way around, you mean...
Copy link to clipboard
Copied
Yes, correct.... I was going to edit and fix it.. but apparently I can't edit my own post...
Copy link to clipboard
Copied
You can change or delete a posting when there are no replies.