Have constant sum total appear in another question on same page | XM Community
Skip to main content
Question

Have constant sum total appear in another question on same page

  • July 30, 2020
  • 4 replies
  • 446 views

I have two questions on a page. The first is a constant sum matrix table and the second is a text entry matrix table. I would like the total value of the constant sum to appear in one of the cells of the second question. See example below:

forqualtricsq.PNG
Is this possible?

Thanks

4 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • July 30, 2020

If you add a page break between the two question, then you can directly add the default choice for those text entry boxes as piped text of previous question.
But, if you want them to be on the same page then using java script on blur event event, you need to get the value from first question and put the value to second question text entry box.


  • Author
  • July 31, 2020

Thanks for response rondev. I am new to java script and uncertain how to proceed. I found this discussion and I assume I would do something similar. Is there a way to reference the total of the constant sum?
https://www.qualtrics.com/community/discussion/9743/display-math-operation-results-real-time


  • Author
  • August 6, 2020

I was able to get to this point by using some code from SurajK in this discussion:
https://www.qualtrics.com/community/discussion/10682/creating-a-grand-total-from-total-boxes-constant-sumI just need to get the totals into the second row, not the first. I'm sure this is simple but my java script skills aren't great. Any ideas?
Capture.PNGHere is the code I used:
Qualtrics.SurveyEngine.addOnReady(function()
{
   /*Place your JavaScript here to run when the page is fully displayed*/
   jQuery('input[type="text"]').change(function(){
var sum1 = jQuery('.SumTotal').eq(0).find('input[type="text"]').val();
var sum2 = jQuery('.SumTotal').eq(1).find('input[type="text"]').val();
var sum3 = jQuery('.SumTotal').eq(2).find('input[type="text"]').val();

jQuery('#QID202').find('input[type="text"]').eq(0).val(sum1);
jQuery('#QID202').find('input[type="text"]').eq(1).val(sum2);
jQuery('#QID202').find('input[type="text"]').eq(2).val(sum3);
});
});


SurajK
QPN Level 3 ●●●
Forum|alt.badge.img+4
  • QPN Level 3 ●●●
  • August 6, 2020

I'm guessing you have two columns only and you want to add the sum of previous questions into the current question but in second row, just change the index of text box (eq) value.
In your case add the below lines,
jQuery('#QID202').find('input[type="text"]').eq(2).val(sum1);
jQuery('#QID202').find('input[type="text"]').eq(3).val(sum2);