How can I automatically display statements which have data in them when they are hidden by JS? | XM Community
Skip to main content

Hello. The code that was provided in another discussion (pasted below) works very well to display one row (i.e., one statement) in a Side by side question, with a plus sign allowing users to add more (hidden) rows. 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 another user in the other discussion 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!

Be the first to reply!

Leave a Reply