Removing the initial zero display on a constant sum question | XM Community
Solved

Removing the initial zero display on a constant sum question

  • 9 October 2020
  • 5 replies
  • 285 views

Userlevel 2
Badge +6

I am trying to remove the default display of zero from a constant sum question.
I normally use this code and it worked for questions with multiple choices.
  var inputWidth = "75px";
var q = jQuery("#"+this.questionId);
q.find('.SumInput').css("width", inputWidth);
q.find('.SumTotal').css("width", inputWidth);
q.find('.InputText').css("width", inputWidth);

var inputs = jQuery("#"+this.questionId+" .SumInput input");
  if(inputs.filter(function() {return this.value != "0";}).length == 0) {
    inputs.val("");
  }
But in this case, I only have one text box and no total box.


icon

Best answer by TomG 9 October 2020, 19:51

View original

5 replies

Userlevel 7
Badge +27

Change
 jQuery("#"+this.questionId+" .SumInput input");
to
 jQuery("#"+this.questionId+" .SumInput");

Userlevel 2
Badge +6

Thanks!

Userlevel 2
Badge +6

Hi TomG ,

So I used the code above for a matrix table with 2 constant sum columns. How can I implement this for the second column (B)?
col A col B
statement 1
statement 2

Userlevel 7
Badge +27

https://www.qualtrics.com/community/discussion/comment/31141#Comment_31141Use:
jQuery("#"+this.questionId+" .c5 > input");
Instead of having to ask every time, you need to learn how to inspect html source and how CSS selectors are written.

Userlevel 2
Badge +6

Thanks!
I try my best to do a search first before I post something. Usually around 80% of what I am looking for, I find just by googling. We have been using Qualtrics for 7 months but we are tasked to convert our complex Confirmit surveys to this platform.
I didn't know about inspecting html sources until 2 days ago when I found this informative post: https://www.qualtrics.com/community/discussion/5819/using-jquery-to-make-a-field-read-only
Usually, someone asks here and a code is posted and I always wonder how they came up with the solution. Now I know.

Leave a Reply