is there a way to dynamically add more free text boxes in a matrix question | XM Community
Skip to main content
Question

is there a way to dynamically add more free text boxes in a matrix question

  • December 27, 2023
  • 4 replies
  • 289 views

Forum|alt.badge.img+3
  • Level 3 ●●●
  • 14 replies

Hi, I am wondering if this is a feature of matrix questions with free text entry. Is there an option for survey respondents to dynamically add more free text entry rows in a matrix question, if for example there are 5 rows in the question, but the respondent has 6 unique entries? 

4 replies

Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+34
  • Level 8 ●●●●●●●●
  • 654 replies
  • December 29, 2023

We cannot have unlimited rows in matrix since we need to specify the max number while programming. Now using JS just show first three rows and hide others, add plus button to show new rows.


Forum|alt.badge.img+3
  • Author
  • Level 3 ●●●
  • 14 replies
  • December 31, 2023

Thank you! that is helpful, is there code to get started with hiding other rows and an add plus button to show new rows? 


Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+34
  • Level 8 ●●●●●●●●
  • 654 replies
  • December 31, 2023

Thank you! that is helpful, is there code to get started with hiding other rows and an add plus button to show new rows? 

Try using the below code:

var that=this.questionId;
jQuery("#"+this.questionId+" tr.ChoiceRow:not(:eq(0))").hide();
jQuery("<input type='button' id='add' value='+' name='+' />").insertAfter("#"+this.questionId+" tr.ChoiceRow:last");
jQuery("#add").on('click',function(){
var c= jQuery("tr.ChoiceRow:visible").length;
jQuery("#"+that+" tr.ChoiceRow:eq("+c+")").show();
});

 


Forum|alt.badge.img+3
  • Author
  • Level 3 ●●●
  • 14 replies
  • January 2, 2024

Thank you! Where would this code go? In the Question Text or the Question Option Response?