Make a text-entry input box read-only in a side-by-side question type | XM Community
Skip to main content

Hi community!
In the second column ("begin after what goal?") of the following side-by-side question, I need to make the text box in just the first row read-only:
sbs annotated.pngHow can I make one specific cell read-only in a side-by-side question?
If this absolutely cannot be done in side-by-side, but you have a solution for a simple text-entry question, I'll take that!
The identifier for that cell is this:

${q://QID240%231/ChoiceTextEntryValue/4/1}

Thanks!
P.S. Separately, If you happen know know some JS that would strip any line breaks/carriage returns that users input in that first column, that would be a MUCH appreciated bonus!!!

You might be able to use the code from @TomG to hide the contents of your matrix cell. Not showing a text entry that you can't type into could be less confusing for your survey taker and you could remove "please leave this blank for Big Goal #1". Just something to try, I don't have JavaScript on my account right now so can't test it out for you. You might want to preview the question and right click on the cell to Inspect Element to get all of the value you want to assign to var cell =
https://community.qualtrics.com/XMcommunity/discussion/2597/how-to-hide-radio-button-element-in-matrix-question


This seems like it's right in the neighborhood, bstrahin!! I just don't have the skills to quite execute.
Are you able to debug my various attempts below? THANKS!
Try #1:
var cell = "2~1~1~TEXT"
jQuery(("#QR~"+this.questionId+"~"+cell).replace(/~/g, "\\\\~")).closest("td").find("").hide();
Try #2:
var cell = "2~1~1~TEXT"
jQuery(("#QR~"+this.questionId+"~"+cell).replace(/~/g, "\\\\~")).prop("disabled" , "true");
jQuery(("#QR~"+this.questionId+"~"+cell).replace(/~/g, "\\\\~")).css("display" , "none");
Try #3:
var cell = "2~1~1~TEXT"
var input = jQuery(("#QR~"+this.questionId+"~"+cell).replace(/~/g, "\\\\~"));
input.prop("disabled",true);
input.closest("td").find("*").hide();
Try #4:
var cell = "2~1~1~TEXT"
var input = jQuery(("#QR~"+this.questionId+"~"+cell+".InputText").replace(/~/g, "\\\\~"));
input.hide();
Here's what I get when I use Inspect in my browser:
input.png


I must admit I am a brain stormer and not a coder. Perhaps TomG can clear things up.
My gut says to try
var cell = "2~1~1"
var input = jQuery(("#QR~"+this.questionID+"~"+cell).replace(/~/g, "\\\\~"));
input.prop("disabled",true);
input.closest("td").find("*").hide();


Unfortunately no-go. But thanks! Pretty impressive for a non-coder.


wscampbell bummer 😞 I hope someone can help you figure this out. Would be a cool capability to have documented on the forum.


wscampbell ,
This will hide the input in the second column of the first row.:
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" tr.Choice").first().find(".SBS2").find("*").hide(); 
});


Thanks TomG for helping!


Thank you so much, TomG! That solved it!
(thanks, too, bstrahin for the conceptual attempt + connecting me to TomG, the hero!)
Does that mean the following should work for a text entry question?
jQuery("#"+this.questionId+" tr.Choice").hide(); 
Can't quite get that to work.


https://community.qualtrics.com/XMcommunity/discussion/comment/47275#Comment_47275No, that will hide the first row of a Side-by-side question (table row (tr) with a class of "Choice"). Different questions use different types of html elements and classes. Use the browser's inspect feature to figure out what they are.
If you want to hide the text input in a text entry question you can use:
jQuery("#"+this.qustionId+" .InputText").hide();


TomG, wow. This is amazing. Thanks!
No need to reply, but in case you have time...
I'm trying to make sure I understand this in general so I can apply this moving forward.
For the side-by-side, the winning code you gave was:
jQuery("#"+this.questionId+" tr.Choice").first().find(".SBS2").find("*").hide(); 
However, when I inspect the page, I see the "SBS2" but not the "tr" or the "Choice":
2022-06-28 13_07_49-Preview - Qualtrics Survey _ Qualtrics Experience Management - Brave.pngJust want to make sure I'd know how to do this for future questions of a different type (e.g., drop-down question on a matrix table).


https://community.qualtrics.com/XMcommunity/discussion/comment/47286#Comment_47286A side by side uses an html table. Navigate up the structure - a td (cell) is always a child of a tr (row).


Leave a Reply