jquery removing default 0 in constant sum question causing answered to be erased when clicking back | XM Community
Skip to main content
I have a collection of constant sum questions which have a jQuery line (see below) removing the default 0 in the input box so that boxes appear blank. That works fine, but when in testing when you go backwards in the survey after answering these questions, the responses are wiped away and the boxes appear blank. We need to have these answers saved if/when a respondent goes back and revisits these questions. Any suggestions?



line used:

jQuery("#"+this.questionId+" li input[type=text]").val("");
Have the script check the values and only change them to blank if they are all 0.
Removed.
```

var inputs = jQuery("#"+this.questionId+" .SumInput input");

if(inputs.filter(function() {return this.value != "0";}).length == 0) {

inputs.val("");

}

```
Removed.
When I tried this, the 0 still appears as the default. It does save the value if you enter one and you can go back to it and check your entries before you submit. Is there a way to remove the prefilled 0 and also not record a 0 in the data if the user does nothing with a question?

Leave a Reply