[英]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.