Qualtrics: Javascript to prevent saving entry from Text Box

*爱你&永不变心* 提交于 2019-12-11 23:28:02

问题


I have one Text Box (also called "Text Entry") in my qualtrics survey in which I want participants to write something but I do not want to have the result saved in my data. I do not want to use the password function, therefore I have used JavaScript at the Text Box level.

The code below works to the extent that whatever participants put in the Text Box it will be set to an empty string the moment they hit the Next-Button.

Qualtrics.SurveyEngine.addOnload(function()
{
    /*Place Your Javascript Below This Line*/
var currentQuestionID = this.getQuestionInfo().QuestionID

var input = $("QR~"+currentQuestionID);


$('NextButton').onclick = function (event) {
     input.value = ""
}
});

The problem: This code only works sometimes. For example when I have two textboxes with the exact same code it only works for the first but not the second one. Similarly for some reason if the textbox is embedded in some other questions it doesn't work either.

Does anybody know how I can make this work either by changing my code or with a completely different solution? Essentially, I just want participants to entry some text which will never be saved in my data and I cannot use the password function.

Solution: One way of solving this would be adding a "Descriptive Text" item in which you can add some simple HTML code:

<p>Please provide your email address:</p><p><br></p>

 <input name="nothing" type="textarea">

回答1:


I don't think JavaScript works well in this case as it can't be guaranteed to run before the page has sent the data.

The best way is to make a dummy HTML "question" which has the appearance of a form but does not save any information.

I tried this out in a test survey by adding a question of type "Descriptive Text", and then in "HTML View" for that question, adding:

<p>This is not a real question, there is just a HTML textarea. </p>
<form id="mydummyform">
<input name="nothing" type="textarea" />
</form>

I found that this sometimes showed the HTML source instead of the form in the survey editor; if it does this, just go to "HTML View" and then "Normal View" and it should resolve correctly. This problem was only in the editor -- it always showed correctly in a preview of the survey.



来源:https://stackoverflow.com/questions/36225619/qualtrics-javascript-to-prevent-saving-entry-from-text-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!