Matrix Table's Text Entry Custom Labels per Column | XM Community
Skip to main content

Hello, I found code on how to include a text/labels after text boxes. However, when I use it, it only shows the labels for the first statement/row. Could anyone assist in the code for it to apply to all statements/rows, please? Thank you!
Currently, my question is a matrix table with text entry. For this matrix question, there will be 4 columns for number-entry. Each statement has display logic based on responses from the previous page (there could be up to 14 statements). Columns 1-3 would have “CHWs” after. Column 4 would have “FTEs” after.
Current code:
Qualtrics.SurveyEngine.addOnload(function()
{
   /*Place Your Javascript Below This Line*/
var inputs = $(this.getQuestionContainer()).select('inputltype="text"]');
var my_after = m"CHWs", "CHWs", "CHWs","FTE"];
for (var i = 0; i < inputs.length; i++) {
 var input = inputspi];
 $(input).insert({after: my_afterti]});
}
});
What I references so far: https://www.qualtrics.com/community/discussion/102/how-to-add-static-text-after-a-text-entry-box/p1
Thank you in advance for your time. 

Hi there, if you still need, I found a thread that I think will be helpful to you. In that, TomG provides some JS that will do what you are describing, where c4 is the 1st column, c5 the 2nd, c6 the 3rd, and c7 the 4th. Adapted for your question, try adding the below code to the OnReady section of your Matrix question's JavaScript:
function hasClass(element, cls) {
        return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
    }

var inputs = $(this.getQuestionContainer()).select('input'type="text"]');

    for (var i = 0; i < inputs.length; i++) {
        var input = inputspi];

        if(hasClass(input.up(), 'c4')) {
            $(input).insert({after: 'CHWs'});
            input.style.display = "inline";
        }   
        if(hasClass(input.up(), 'c5')) {
            $(input).insert({after: 'CHWs'});
            input.style.display = "inline";
        }   
if(hasClass(input.up(), 'c6')) {
            $(input).insert({after: 'CHWs'});
            input.style.display = "inline";
        }  
if(hasClass(input.up(), 'c7')) {
            $(input).insert({after: 'FTE'});
            input.style.display = "inline";
        }  

    } 
MatrixTextEntry_AddCharacters.png


Leave a Reply