繁体   English   中英

如何在定标中创建表示是否选中复选框的javascript变量?

[英]How do I create a javascript variable in qualtrics that represents if a checkbox is ticked or not?

我有一个用于弹出按钮的代码,用于确认受访者不同意同意书将终止调查:

Qualtrics.SurveyEngine.addOnReady(function()
{
 /*Place your JavaScript here to run when the page is fully displayed*/
const that=this;
    this.hideNextButton();
    var btn = jQuery('<div id="Buttons"><input id="CustomButton" class="NextButton Button"  title="  Next  " type="button" name="NextButton" value=" Next  "  aria-label="Next"></div>')
    jQuery('#Buttons').append(btn);

    jQuery('#CustomButton').on('click', function(){
        var txt;
        var e= jQuery("[id='QID107']").val()
        if(e==""){
                    var r = confirm("The survey will be terminated if you do not agree with the consent form. Are you sure you wish to continue?");
                     if (r == true) {
                            that.clickNextButton();
                     } else {

                    }
        }
    });
});

我是javascript的新手,希望使用变量e来指代问题QID107的选择,该问题是同意书的单个复选框。 我只希望弹出消息为“调查将终止(...)。确定要继续吗?”。 如果未选中该复选框并且e为空,则显示此字段。 if e==""那就是我要处理的事情。 无论同意问题的答案如何,该条件看起来都是正确的,所以我认为我做错了事,但不知道是什么。 如何在此脚本中创建该条件? 我如何正确地将对同意书的答复放入e

编辑:如果复选框为空,则问题的条件是终止调查,因此,如果复选框为空,则that.clickNextButton()会激活该终止条件。

不必检查带有空字符串的'e'的相等性,而必须检查它的检查状态。

jQuery("[id='QID107']").is(":checked")

这将返回复选框的状态,由此您将知道复选框是否已选中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM