Format Matrix to Read Right to Left (flip matrix to have statements on left side) | XM Community
Skip to main content

I’m collecting data in a few different languages, and some of these languages are read from right to left (e.g., Arabic, Hebrew). I want to “flip” my matrix table to have my statements on the right-hand side of the matrix (see example below). I found some code (HERE) but I haven’t been able to get it to work. Can anyone help me get this code to work in my survey? (I don’t want this to affect the mobile version of the survey - the mobile version should still present as a single “matrix statement” with the response options underneath.)

 

 

I think the following code might work.

 

Qualtrics.SurveyEngine.addOnload(function()
{

    // Select the matrix table question
    var matrixTable = document.querySelector('.QuestionOuter.Matrix');

    if (matrixTable) {
        // Select the table inside the matrix table question
        var table = matrixTable.querySelector('.ChoiceStructure');

        if (table) {
            // Get the number of rows (statements) and columns (scale options) in the table
            var numRows = table.rows.length;

            // Iterate over each row
            for (var i = 0; i < numRows; i++) {
                // Reverse the order of cells in the row
                var cells = Array.from(table.rows/i].cells);
                cells.reverse();
                for (var j = 0; j < cells.length; j++) {
                    table.rows(i].appendChild(cellslj]);
                }
            }
        }
    }


});


@APNatoli,

If you translate the survey into a right-to-left language (Hebrew, Arabic, etc.) Qualtrics will automatically flip the matrix when right-to-left translation is displayed. So, I don’t think you need any code.


Leave a Reply