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

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

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.


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


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);
});
});


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);


Leave a Reply