JavaScript in Loop & Merge | XM Community
Skip to main content

I'm using JS code to make each cell in column in a matrix table read only - see below...
jQuery("#QR\\\\~QID90\\\\~13\\\\~1").prop("readonly",true);
jQuery("#QR\\\\~QID90\\\\~4\\\\~1").prop("readonly",true);
jQuery("#QR\\\\~QID90\\\\~6\\\\~1").prop("readonly",true);
I realized from inspecting the cells during the survey that the id changes during the survey, so I updated the code to below to cater for each loop:
jQuery("#QR\\\\~1\\\\~QID90\\\\~13\\\\~1").prop("readonly",true);
jQuery("#QR\\\\~1\\\\~QID90\\\\~4\\\\~1").prop("readonly",true);
jQuery("#QR\\\\~1\\\\~QID90\\\\~6\\\\~1").prop("readonly",true);
jQuery("#QR\\\\~2\\\\~QID90\\\\~13\\\\~1").prop("readonly",true);
jQuery("#QR\\\\~2\\\\~QID90\\\\~4\\\\~1").prop("readonly",true);
jQuery("#QR\\\\~2\\\\~QID90\\\\~6\\\\~1").prop("readonly",true);
However, this still didn't work. What am I doing wrong? FOUND THE ISSUE - WAS MISSING AN UNDERSCORE - SORRY
But, if there is an easier way to make a whole column read only (rather than one cell at a time) that would be good to know.

Yes:
jQuery("#"+this.questionId+" .c4 input").prop("readonly",true);
It is rarely necessary to use element ids to find elements.


https://www.qualtrics.com/community/discussion/comment/28847#Comment_28847Thanks - this will make my life a lot easier :-)


https://www.qualtrics.com/community/discussion/comment/28847#Comment_28847Is this the correct syntax to make the first column of a side-by-side table read-only?
jQuery("#"+this.questionId+" .SBS1").prop("readonly",true);

n.b. if I use the syntax  jQuery("#"+this.questionId+" .SBS1").hide(); - I can hide the column, but don't appear to be able to make the column read only??


https://www.qualtrics.com/community/discussion/comment/29710#Comment_29710Use:
jQuery("#"+this.questionId+" .SBS1 .InputText").prop("readonly",true);


https://www.qualtrics.com/community/discussion/comment/29712#Comment_29712Thanks Tom


Leave a Reply