Swap Columns And Rows Of A Grid Question (Vertical Single Choice)

If you want to display single choice in a Radio Button Grid vertically this JavaScript will do just this but record the data in the same format by row.

Check it out in an example survey!


Add this survey to your US account or your EU account.

Paste the below JavaScript in a JavaScript action on the page where your Radio Button Grid resides.

We recommend setting logic on this action so that it is only displayed if ismobile = false, especially if you are using the One-at-a-time interaction under Style > Layout > Mobile Interaction; otherwise it will interfere with how the questions are displayed on mobile.

$(function() {
    var table = $('.sg-table');
    table.find('thead tr').detach().prependTo( table.find('tbody') );
    var t = table.find('tbody').eq(0);
    var r = t.find('tr');
    var cols= r.length;
    var rows= r.eq(0).find('td,th').length;
    var cell, next, tem, i = 0;
    var tb= $('<tbody></tbody>');

        cell= 0;
        tem= $('<tr></tr>');
            next= r.eq(cell++).find('td,th').eq(0);
        .find('tbody tr:eq(0)')
        .appendTo( table.find('thead') )
            $(this).replaceWith('<th scope="col">'+$(this).html()+'</th>');
        .find('tbody tr th:first-child')
            $(this).replaceWith('<td scope="row">'+$(this).html()+'</td>');

$("td").click(function() { 
      $selector = $(this).parent("tr").children().index($(this)) + 1; 
  //$(".sg-table tr td:nth-child("+$selector+")").fadeTo(300,0.4); //optional fading of column after ticking script for usability   

  $(".sg-type-table-radio input:radio").unbind();


Scripting and Other Custom Solutions

We’re always happy to help you debug any documented script that is used as is. That said, we do not have the resources to write scripts on demand or to debug a customized script.

If you have customization ideas that you haven't figured out how to tackle, we're happy to be a sounding board for Alchemer features and functionality ideas that might meet your needs. Beyond this, check out our Professional Services; these folks have the scripting chops to help you to achieve what you are looking for!

Basic Standard Market Research HR Professional Full Access Reporting
Free Individual Team & Enterprise
Feature Included In