0

I'm trying to display the value of a slider choice on Qualtrics.

I have tried all the solutions proposed here: How to get a slider's value in Qualtrics using jQuery?

I am especially interested in being able to do operations with the value chosen. For example, if someone picks a value of 50 (between 0 and 100). I'd like to show this value multiplied by 5 as well (250).

Also, I'd like to show the values of the slider below the slider, rather than in the text box below.

Below is the code that I copied from a different question. The problem is that the value does not adjust when I move the slider.

Qualtrics.SurveyEngine.addOnload(function() {
/*Place your JavaScript here to run when the page loads*/
var result=0;
var otherend= 0;

this.questionclick = function(event,element){
result = this.getChoiceValue(1);
endupdate();
document.getElementById("otherend").innerHTML=otherend;
document.getElementById("result").innerHTML=result;
}

function endupdate() {
   otherend=100-result;
}
 }); 

Here is a preview of my survey: https://rady.ca1.qualtrics.com/jfe/preview/SV_d1254aUFRjR2yLH?Q_SurveyVersionID=current&Q_CHL=preview

Could you help me figure out why the value shown does not adapt when I move the slider? Thanks

msg
  • 21
  • 5
  • Actually, your preview works for me. If you have managed to solve it, could you answer this question by yourselves and accept your answer? – kamila Dec 08 '18 at 18:30

1 Answers1

0

Thanks for the reminder. I posted the question on Qualtrics community and got lots of help. I suggest using that forum when you have Qualtrics questions.

Below is the JS

Qualtrics.SurveyEngine.addOnReady(function()
{
    /*Place your JavaScript here to run when the page is fully displayed*/
var that=this.questionId;
    jQuery("<p style='width:400%'> \
                    <br><strong><u>PARTICIPANT A</u> gets <span id='currA'>0 \
                    </span> points</strong> worth 1 cent each. \
                    She gets <u><span id='totalA'>0</span></u> cents</p>").insertAfter("tr.First");
 //   jQuery("<p style='width:100%'><span id='currB'>0</span> points for <u>PARTICIPANT B</u> worth 2 cent each. She gets <u><span id='totalB'>0</span></u> cents</p>").insertAfter("tr.First");
    jQuery(document).on('change', function(){

        var A=parseInt(jQuery("[id='"+that+"~1~result']").val());
        jQuery("#currA").text(A);
        jQuery("#totalA").text(A);
   /*     var B=parseInt(jQuery("[id='"+that+"~2~result']").val());
        jQuery("#currB").text(B);
        jQuery("#totalB").text(B*2);    
*/
    });
});
msg
  • 21
  • 5