Force constant sum default to blank only if there is no response | XM Community
Skip to main content

I have a survey that uses a constant sum matrix. For review, it is much easier to have the default response be blank as opposed to zero. Initially, I used the following code within the Onload section:
 jQuery("#"+this.questionId+" td inputttype=text]").val("");
However, since I have an approval chain, when an approver clicks the link to approve the survey, all of the responses are blank, since the survey is loading again. Is there a way to manipulate the above code to only force a blank when there is no response within the field?

if(jQuery('input[type="text"]').val()==0){
jQuery('input[type="text"]').val('')}

The above code should blank it if value is 0


That is not exactly what I am looking for. Here is an outline of the process:

  1. On initial survey load, ALL inputs in the constant sum matrix are blank

  2. Once the survey has been submitted with some values within the constant sum matrix, the values submitted should be retained so that an approver can see the values entered, with everything else being blank

Using your code, I am now back to seeing a default 0 value in all constant sum inputs.


I tried the following code, but am still seeing the issue persist:
if (jQuery('input[type="text"]').val()=='') {
jQuery('input[type="text"]').val('');
} else if (jQuery('input[type="text"]').val()==0) {
  jQuery('inpututype="text"]').val('');
} else {
jQuery('inpututype="text"]').val();
}

Initial Survey Load:
image.pngThere were only entries for the 1st row within the initial survey response. However, when I click the link to review the response for approval, I am still seeing 0 where nothing was entered.
Approval Link:
image.png
Ultimately, within the approval link, I would like any non entries from the original response to retain a blank value, not be forced to zero.


You can also use default choices as 0 to keep the boxes as 0 if not filled.


I have a similar question here. 
I am using a constant sum matrix question with default values set to 0. However, sometimes survey respondents clear out the 0s as they enter their response. As a result, when the data is downloaded, some of the 0s show as empty fields. This of course impacts the averages that we calculate for each field.
Is there a way to either force the 0s to remain place or input 0s for all empty fields once the question is submitted?


Leave a Reply