Have constant sum total appear in another question on same page

Chris2020Chris2020 Community Member Qubie ✭

Have constant sum total appear in another question on same page

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:



Is this possible?


Thanks

Answers

  • rondevrondev Community Member - Trial User Wizard ✭✭✭✭✭

    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.

  • Chris2020Chris2020 Community Member Qubie ✭

    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?


  • Chris2020Chris2020 Community Member Qubie ✭

    I was able to get to this point by using some code from @SurajK in this discussion:

    I 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?

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

    });

    });

  • SurajKSurajK IndiaCommunity Member Sage ✭✭✭

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

Sign In to Comment