Qualtrics:防止从文本框中保存条目的Javascript [英] Qualtrics: Javascript to prevent saving entry from Text Box

查看:114
本文介绍了Qualtrics:防止从文本框中保存条目的Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的定性调查中有一个文本框(也称为文本输入"),我希望参与者在其中写一些东西,但我不想将结果保存在数据中.我不想使用密码功能,因此我在文本框级别使用了JavaScript.

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.

解决方案:解决此问题的一种方法是添加描述性文本"项,您可以在其中添加一些简单的HTML代码:

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">

推荐答案

在这种情况下,我认为JavaScript效果不佳,因为不能保证在页面发送数据之前就可以运行它.

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.

最好的方法是制作一个虚拟HTML问题",该问题具有表单外观,但不保存任何信息.

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

我在测试调查中通过添加类型为描述性文本"的问题对此进行了尝试,然后在"HTML视图"中添加了该问题,并添加了以下内容:

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>

我发现有时显示的是HTML源代码,而不是调查编辑器中的表格;如果这样做,则只需转到"HTML视图",然后转到普通视图",它应该可以正确解析.这个问题仅存在于编辑器中-始终在调查的预览中正确显示.

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.

这篇关于Qualtrics:防止从文本框中保存条目的Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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