Hello, in my study, if the sliders are marked as 50, the participants are paid 100 ECU. The income obtained from the sliders is called labor income. I used an embedded data and JS code to make this calculation. However, sometimes the slider income is calculated and sometimes it is not. What could be the reason for this?
Is your slider question and embedded data and the next question, are they in same block?
Are you using any randomizer?
It is as in the attached screenshot.
Is your slider question and embedded data and the next question, are they in same block?
Are you using any randomizer?
No, I am not using any randomizer.
can you also show how the embedded data is being stored. and whats the purpose of JS?
can you also show how the embedded data is being stored
Thank you. Of course. Here it is;

can you also show how the embedded data is being stored
Thank you. Of course. Here it is;

so, the purpose of JS is to store the values for Tota_ECU. IS that right?
can you also show how the embedded data is being stored
Thank you. Of course. Here it is;

so, the purpose of JS is to store the values for Tota_ECU. IS that right?
Yes, you are right.
Here is my JS code:
Qualtrics.SurveyEngine.addOnload(function() {
var that = this;
var timer = 20; // 20 seconds timer
var interval = setInterval(function() {
timer--;
if (timer <= 0) {
clearInterval(interval);
that.clickNextButton();
}
}, 1000);
// Disable sliders after 20 seconds
setTimeout(function() {
jQuery('.q-slider input type="range"]').prop('disabled', true);
}, 20000);
});
Qualtrics.SurveyEngine.addOnReady(function() {
var that = this;
var earnings = 0;
// Calculate earnings based on sliders marked as 50%
jQuery('.q-slider inputdtype="range"]').on('change', function() {
var value = jQuery(this).val();
if (value == 50) {
earnings += 100;
}
// Update embedded data each time a slider is changed
that.setEmbeddedData('earnings', earnings);
});
});
Qualtrics.SurveyEngine.addOnReady(function() {
var totalPercentage = 0;
for (var i = 1; i <= 10; i++) {
var sliderValue = parseInt("${q://QID" + i + "/ChoiceTextEntryValue}");
if (!isNaN(sliderValue)) {
totalPercentage += sliderValue;
}
}
totalPercentage = totalPercentage / 10;
Qualtrics.SurveyEngine.setEmbeddedData("totalPercentage", totalPercentage);
});
Qualtrics.SurveyEngine.addOnReady(function() {
var totalPercentage = 0;
for (var i = 1; i <= 10; i++) {
var sliderValue = parseInt("${q://QID" + i + "/ChoiceTextEntryValue}");
console.log("Slider " + i + " value: " + sliderValue);
if (!isNaN(sliderValue)) {
totalPercentage += sliderValue;
}
}
totalPercentage = totalPercentage / 10;
console.log("Total Percentage: " + totalPercentage);
Qualtrics.SurveyEngine.setEmbeddedData("totalPercentage", totalPercentage);
});
Qualtrics.SurveyEngine.addOnload(function() {
var totalECU = 0;
var that = this;
this.questionclick = function(event, element) {
totalECU = 0;
for (var i = 1; i <= 10; i++) {
var sliderValue = that.getChoiceValue(i);
if (sliderValue == 50) {
totalECU += 100;
}
}
Qualtrics.SurveyEngine.setEmbeddedData("Total_ECU", totalECU);
};
});
Here is one error:
var sliderValue = parseInt("${q://QID" + i + "/ChoiceTextEntryValue}");
will always result in NaN. You can’t dynamically build piped strings. Pipes are resolved on the server before the page is sent to the browser. So you are always parsing a non-numeric string.
Here is one error:
var sliderValue = parseInt("${q://QID" + i + "/ChoiceTextEntryValue}");
will always result in NaN. You can’t dynamically build piped strings. Pipes are resolved on the server before the page is sent to the browser. So you are always parsing a non-numeric string.
Okay thank you so much. What do ı need to use instead of it? or should ı delete it?
Here is one error:
var sliderValue = parseInt("${q://QID" + i + "/ChoiceTextEntryValue}");
will always result in NaN. You can’t dynamically build piped strings. Pipes are resolved on the server before the page is sent to the browser. So you are always parsing a non-numeric string.
Okay thank you so much. What do ı need to use instead of it? or should ı delete it?
I don’t know what totalPercentage is used for. The way you are attempting to calculate it doesn’t make sense (you are trying to get values from 10 different questions with QIDs QID1 through QID10).
Here is one error:
var sliderValue = parseInt("${q://QID" + i + "/ChoiceTextEntryValue}");
will always result in NaN. You can’t dynamically build piped strings. Pipes are resolved on the server before the page is sent to the browser. So you are always parsing a non-numeric string.
Okay thank you so much. What do ı need to use instead of it? or should ı delete it?
I don’t know what totalPercentage is used for. The way you are attempting to calculate it doesn’t make sense (you are trying to get values from 10 different questions with QIDs QID1 through QID10).
Yes, there are 10 sliders in the question. Totalpercentage allows adding 100 ECU to the sliders marked as 50%.
Yes, there are 10 sliders in the question. Totalpercentage allows adding 100 ECU to the sliders marked as 50%.
For the current question, get the slider input values (like you did in your change function) or use the API’s getChoiceValue() function.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.