Hello,
I have a value of minutes (the answer of QID1). And if this value is over than 60, I want to convert this to hours and minutes.
Qualtrics.SurveyEngine.addOnReady(function()
{
var hours = parseInt(("${q://QID1/ChoiceTextEntryValue}") / 60);
var mins = parseInt(("${q://QID1/ChoiceTextEntryValue}") % 60);
var t1;
if(hours = 0){
t1 == mins;
}
Qualtrics.SurveyEngine.setEmbeddedData("t1", mins + " minutes");
else if(hours >= 1){
t1 == hours;
}
Qualtrics.SurveyEngine.setEmbeddedData("t1", hours + " hours " + mins + " minutes");
});
The problem is the "else if" part. I know the current code is wrong because it is showing only hours.
Could anyone help me correct this code?
Thank you very much in advance.
Page 1 / 1
Hello @jhwang ,
Here is the updated code:
var hours = parseInt(("${q://QID1/ChoiceTextEntryValue}") / 60);
var mins = parseInt(("${q://QID1/ChoiceTextEntryValue}") % 60);
if(hours == 0){
Qualtrics.SurveyEngine.setEmbeddedData("t1", mins + " minutes");
}
else {
Qualtrics.SurveyEngine.setEmbeddedData("t1", hours + " hours " + mins + " minutes");
}
Here is the updated code:
var hours = parseInt(("${q://QID1/ChoiceTextEntryValue}") / 60);
var mins = parseInt(("${q://QID1/ChoiceTextEntryValue}") % 60);
if(hours == 0){
Qualtrics.SurveyEngine.setEmbeddedData("t1", mins + " minutes");
}
else {
Qualtrics.SurveyEngine.setEmbeddedData("t1", hours + " hours " + mins + " minutes");
}
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.