Solved
Round quota to nearest multiple of 10 using Java in Qualtrics Questionnaire
Dear all,
I would like to generate a question in my survey, where the current number of participants rounded to the next multiple of 10 is displayed.
Qualtrics support told me I need to use Java - as I am not familiar with using Java, I'd appreciate your help!
Specifically I would like to display to the participants the text:
_"Number of participants so far: < X"_
Where X represents the next multiple of 10 of number of participants. I have already created a quota named "QuotaCount", which counts the number of participants of the survey.
Therefore the JavaScript should generate i.e. the following:
* if QuotaCount = 0 -> X=10
* if QuotaCount = 1 -> X=10
* if QuotaCount = 6 -> X=10
* if QuotaCount = 10 -> X=20
* if QuotaCount = 11 -> X=20 etc.
I have found the folowing formular online: (parseInt(x / 10, 10) + 1) * 10 - not sure though how to use it in context of the java script.
*
Looking forward to your answers.
Thank you and best regards,
Best answer by TomG
Let's say your html looks like:
```
Number of participants so far: < <span id="X"></span>
```
Then add the following js to the addOnload function:
```
var quota = parseInt("${qo://quota pipe string goes here}");
jQuery("#X").html((parseInt(quota/10, 10)+1)*10);
```
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.