Skip to main content
Participant
August 1, 2023
Question

Getting text to show based on score conditions

  • August 1, 2023
  • 1 reply
  • 974 views

Hi all, is there a way I can get an image or text to display backed on the score in a text field? I have the text field that sums other scores in the assessment sheet. I would like a non-editable text to show based on this overall score i.e. score 0-49.99 shows 'fail', 50-60 shows 'Sat', 60-70 shows 'good' etc. 

 

Thanks 🙏

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 1, 2023

Sure. You can use something like this as the custom calculation script of that field (let's say the other field is called "Score"):

 

 

var score = Number(this.getField("Score").valueAsString);
if (score<50) event.value = "Fail";
else if (score<=60) event.value = "Sat";
else if (score<=70) event.value = "Good";
// etc.

 

[edited: small mistake in the code fixed]

 

LBleijieAuthor
Participant
August 1, 2023

Thanks Try67. When I put that in, it says there is a ) missing after argument list 1. I can see there is an opening ( but not sure where to put the closing one. 

LBleijieAuthor
Participant
August 2, 2023

I fixed it, just put it where I thought it would fit to close the argument. Works perfectly, thank you so much 👍