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

JavaScript in Loop & Merge


MikeW
Level 5 ●●●●●
Forum|alt.badge.img+14
  • Level 5 ●●●●●
  • 137 replies

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.

Best answer by TomG

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

View original

5 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5940 replies
  • Answer
  • August 10, 2020

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


MikeW
Level 5 ●●●●●
Forum|alt.badge.img+14
  • Author
  • Level 5 ●●●●●
  • 137 replies
  • August 11, 2020

MikeW
Level 5 ●●●●●
Forum|alt.badge.img+14
  • Author
  • Level 5 ●●●●●
  • 137 replies
  • August 28, 2020

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??


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5940 replies
  • August 28, 2020

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


MikeW
Level 5 ●●●●●
Forum|alt.badge.img+14
  • Author
  • Level 5 ●●●●●
  • 137 replies
  • August 28, 2020

Leave a Reply