Alternative to JS: We can ask the user to enter( open text with number and range (0-10) validation ) how many number of people contact information can you provide. Now, based on this question answer, we can add display logic at option level i.e (option 1 will have no display logic), option 2 will have display logic- to show if open text has answer '2' or greater or equal to two, similarly option 3 will have logic- to show if open text has answer '3' or greater than or equal to three
Paste the below code in the Side-by-Side question js(onReady)
var that=this.questionId;
jQuery("#"+this.questionId+" tr.Choice:not(:eq(0))").hide();
jQuery("<input type='button' id='add' value='+' name='+' />").insertAfter("#"+this.questionId+" tr.Choice:last");
jQuery("#add").on('click',function(){
var c= jQuery("tr.Choice:visible").length;
jQuery("#"+that+" tr.Choice:eq("+c+")").show();
});
Note: The above code will work if there is no custom validation on any of the question of the page.
> @Shashi Is this code easily adaptable for text entry forms? or if that isnt possible for matrix questions?
The code is not adaptable to text entry forms
> @Shashi Thanks for your quick reply. Is it possible matrix questions?
Change Choice to `ChoiceRow` , doing this it will work for matrix question
I used the code I noted above to start with 3 rows instead of 1.
Replace
`jQuery("#"+this.questionId+" tr.Choice:not(:eq(0))").hide();`
with
`jQuery("#"+this.questionId+" tr.Choice:not(:lt(3))").hide();`
https://www.qualtrics.com/community/discussion/comment/10464#Comment_10464Hello Nadaly ,
I am using this code in my side-by-side question with 100 rows. I want my survey to display 9 rows at the beginning so I've changed 3 to 9.
Qualtrics.SurveyEngine.addOnReady(function()
{
var that=this.questionId;
jQuery("#"+this.questionId+" tr.Choice:not(:lt(9))").hide();
jQuery("").insertAfter("#"+this.questionId+" tr.Choice:last");
jQuery("#add").on('click',function(){
var c= jQuery("tr.Choice:visible").length;
jQuery("#"+that+" tr.Choice:eq("+c+")").show();
});
});
However when I preview the question and use the "add" button, the additional rows did not come up in the right order (pls see below)
I'm not sure how to debug this, appreciate any help!!
Hello. The code that was provided earlier in this discussion (pasted below) works very well to display one row, with a plus sign allowing users to add more (hidden) rows (and by rows I mean statements in a Side by side question). The only imperfection I have found is that sometimes, when adding a new row, the numbering of the rows is not sequential. The first row that appears always seems to be labelled "1", and usually the subsequent rows are "2", "3", etc., but sometimes that isn't the case (e.g., "2" is followed by "4").
var that=this.questionId;
jQuery("#"+this.questionId+" tr.Choice:not(:eq(0))").hide();
jQuery("").insertAfter("#"+this.questionId+" tr.Choice:last");
jQuery("#add").on('click',function(){
var c= jQuery("tr.Choice:visible").length;
jQuery("#"+that+" tr.Choice:eq("+c+")").show();
});
I have run into two issues with this, however, and I hope someone can help.
The first issue is when someone enters a few statements/rows (let's say three) in one of those questions and they then move on to the next page. If they go back to the page where they had entered those rows, only one is displayed. If they click the plus sign enough times, they will see all the data they had entered. Is there any way to have it automatically display all rows/statements that have had data entered into them by the user?
The second issue is kind of the same thing, but it has to do with the Response Summary page. We use the response summary at the end of the survey to allow people to review their responses, go back and correct anything, if necessary, and to download the PDF of the Response Summary. Unfortunately, the same issue occurs on this page where only the first row/statement appears in the summary. The plus button is there and can be clicked on to see more, but that is not ideal and doesn't help at all in the PDF, which we encourage them to download. Clicking the plus sign is not only not ideal, but sometimes it doesn't work properly. As skwok pointed out, the rows that appear may be random, meaning that on this Response Summary page, you may click the plus sign to see all your answers, but it may not show them to you since the rows displayed aren't necessarily the ones you entered data into.
Can anyone help with this? Thank you!
Hello LouRisc! I'm curious if someone was able to help you with this? I'm having this issue where only the first entry shows up. Thank you!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.