如何获取Qualtrics上的滑块值?

时间:2018-09-10 19:05:16

标签: javascript jquery slider

我正在尝试在Qualtrics上显示滑块选择的值。

我尝试了这里提出的所有解决方案: How to get a slider's value in Qualtrics using jQuery?

我对能够使用所选值进行操作特别感兴趣。例如,如果某人选择的值为50(0到100之间)。我还要显示此值乘以5(250)。

此外,我想在滑块下方而不是在下面的文本框中显示滑块的值。

下面是我从另一个问题复制的代码。问题是当我移动滑块时该值不会调整。

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;
}
 }); 

以下是我的调查的预览: https://rady.ca1.qualtrics.com/jfe/preview/SV_d1254aUFRjR2yLH?Q_SurveyVersionID=current&Q_CHL=preview

您能帮我弄清楚为什么在移动滑块时显示的值不适应吗?谢谢

1 个答案:

答案 0 :(得分:0)

感谢您的提醒。我在Qualtrics社区上发布了问题,并获得了很多帮助。如果您对Qualtrics有疑问,建议您使用该论坛。

下面是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);    
*/
    });
});