Hello,
I am using simple layout. I have a form field with two inputs, both are set to display default choices of 0. This works as expected. When the respondent clicks into one of the fields, I would like for the 0 to disappear (instead of the respondent having to manually backspace or delete the 0).
In the question's JavaScript, I am using the following code, but it isn't working (I do have the jQuery call in the header). I'm guessing below code needs to be modified because I am using the simple layout. Suggestions?
Qualtrics.SurveyEngine.addOnload(function()
{
jQuery("#question-"+this.questionId+".text-input").focus(function() {
if(this.value == "0") {
this.value = "";
}
});
Alternatively, if above will not work, I have also tried removing the 0 as default choices, and using the code below to set default text instead. This works as expected, the 0’s are appearing as default text. However, I would like to record the 0 as a response if the respondent does not enter anything into the field. In other words, let’s say in field A they enter 5, and field B they do not enter anything, I want field A to record 5 and field B to record 0 as the response. This unfortunately does not work, field B records as blank, which is not ideal for me because we need to record the actual 0, not a blank field (this also has implications because it is a forced response, eg the user would have to manually enter 0, and we don’t want to require them to do that).
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
jQuery("#question-"+this.questionId+" .text-input").attr("placeholder","0");
});
Thank you!