Counting Matrix Text Boxes | XM Community
Skip to main content
Hi all, I'm fairly new to Qualtrics and have not been able to scour an answer from the support pages or forums.

What I have is a matrix with up-to 10 text-entry boxes with some JS that I found on the forums to show the user 3, but allow them to add more.



!



What I would like to is compare the number of boxes with text entered to the count of a multi-select question (below) as display logic.

!



The idea is to display additional questions if the number of 'text boxes' is greater than the 2019 column total.



The approach I've tried is to: embed the count of text boxes and compare that to the pipe of the count for the 2019 multi-select question.



What I don't believe is working is the count of the text boxes (generally trying to use SelectChoiceCount) based on the module on Piped Text.



Is there any way to count the text boxes? Or other ways to make this comparison?



Thanks for any insights!
I was able to adapt this example to count the boxes using branch logic and embeds following this example:

https://stackoverflow.com/questions/50416475/counting-number-of-text-entry-answers-on-qualtrics-survey.



The solution works, but the branch logic ate my back arrow!



So I've trying to adapt some jQuery code to Qualtrics and placing the embed before all the blcoks. Just not quite sure how to call the function.



jQuery.fn.extend({

countNotEmptyInputs: function() {

var count = 0;

this.each(function() {

if ($(this).is("input:text") && $(this).val().length > 0) {

count++;

}

});

return count;

}

});



var count =



console.log(count)

Qualtrics.SurveyEngine.setEmbeddedData( 'count', Count );

Leave a Reply