如何使用 jQuery 在 Qualtrics 中获取滑块的值? [英] How to get a slider's value in Qualtrics using jQuery?

查看:12
本文介绍了如何使用 jQuery 在 Qualtrics 中获取滑块的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Qualtrics 中获取滑块的值以向用户显示(转换)它.

I need to get the value of a slider in Qualtrics to display (a transformation of) it to the user.

Here is the page I am working on, so you can understand what follows. I have tried many different things, none of which works. My first idea was of course:

var val = $j('#QID11~1~toolTip').text();
$j('#value').text(val)

Nothing shows up. Then, I tried to use the input:

var val = $j("input").attr("value");
$j('#value').text(val);

(Or alternatively, $j('#QID11~1~result') instead of $j("input"), or .val() instead of .attr("value")) Same thing: nothing shows up.

However, interestingly, when I replace attr("value") by e.g. attr("type"), the type ("hidden") shows up. It seems that, as the value is not set when the page first loads, jQuery cannot find it.

Can someone give me an hand on this?

解决方案

You can do it using prototypejs like this:

Qualtrics.SurveyEngine.addOnload(function() {
    var current = $('current');
    var result1 = $(this.questiondId + "~1~result");
    new Form.Element.Observer(result1, 0.25, function() {
        current.update(result1.getValue());
    });
});

The corresponding question text to display the current value is:

Current value is: <span id="current">0</span>%

Update (Screen shots as requested):

这篇关于如何使用 jQuery 在 Qualtrics 中获取滑块的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆