Qualtrics:JavaScript-文本输入 [英] Qualtrics: javascript - text entry

查看:132
本文介绍了Qualtrics:JavaScript-文本输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计了一个Qualtrics调查,其中包括一个文本输入问题.我在这里使用了一个表格,其中包含10个文本输入框.我希望参与者至少填写5个方框(10个方框中的任何5个方框都可以).我认为验证不是一个好主意,因为在很多情况下,您至少要完成10个文本框中的5个,对于每个文本框,填充它和不填充它都是可以的,只要总和竞争的文本框不少于5个.

I designed a Qualtrics survey which includes a text entry question. I used a form here and it contained 10 text entry boxes. I want participants to fill in at least 5 boxes (any 5 boxes out the 10 is okay). I don't think validation is a good idea because there are so many possible cases when you complete at least 5 text boxes out of 10. For every text box, both filling in it and not filling it are okay, as long as the total competed text boxes are no less than 5.

所以我试图通过javascript做到这一点.这是我的代码,但无法正常工作.请告诉我如何更改它.谢谢!

So I tried to do this through javascript. And here is my code but it cannot work. Please tell me how to change it. Thanks!!

Qualtrics.SurveyEngine.addOnload(function()
{

    //disables the next button on the page
    this.disableNextButton();

    var choicesID=this.getQuestionInfo().Choices.Key


    while (1)
    {
        var t=0
        for (var i=0;i<choicesID.length;i++)
        {
            choicetext=this.getTextValue(choicesID[i])
            if (choicetext.length != 0)
            {
                t=t+1
            }
        }

        if (t<=4) continue;
    }

    this.enableNextButton();
});

推荐答案

很抱歉,您是坏消息的承担者,但您还差得远.您的脚本有很多错误,但是最大的问题是,它会尝试检查在问题加载时已回答了多少个问题,这对您没有任何好处.您将需要使用事件监听器来持续计数.

Sorry to be the bearer of bad news, but you are way off. Your script has a number of errors, but the biggest problem is that it attempts to check how many have been answered when the question loads, which doesn't do you any good. You would need to keep an on-going count using an event listener.

我建议一种不需要任何JavaScript或自定义验证的替代方法.使用多选,多选问题,并为每个答案选项打开允许文本输入/强制响应的功能.然后只需将最小答案数设置为5.

I suggest an alternative approach that doesn't require any JavaScript or custom validation. Use a multiple choice, multiple select question with allow text entry / force response turned on for each answer option. Then just set the minimum number of answers to 5.

这篇关于Qualtrics:JavaScript-文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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