Single selection on grid columns

Compatibility: IdSurvey 6 IdSurvey 7

This javascript can be used in simple grids to enforce a single selection on grid columns (the value of the columns can be selected only once in the grid). This script works only with single select grids.


Attention: number of columns and rows has to be the same!

Paste the script in the Client script box you find in the gearwheel button of the page.


    var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && $(window).width() <= 800; var isMobileBrowser = (typeof _customCheckMobileBrowser == "function") ? _customCheckMobileBrowser() : isMobile; if(isMobileBrowser){ $(".survey-page-wrapper #page .group-question-sub-elements > .sub-elements-wrapper :radio").on("change", function(){
        var main = $(this).closest(".main-responses");        
        var li = $(this).closest("li");
        var index = main.find("li").index(li);
        var currentRadio = $(this).closest(".sub-elements-wrapper");

        $(".survey-page-wrapper .group-question-sub-elements > .sub-elements-wrapper .sub-elements-wrapper").each(function(){
            if($(this).find(".main-responses").find("li").eq(index).find(":radio").prop("checked") == true)
              $(this).find(".main-responses").find("li").eq(index).find(":radio").prop("checked", false);

      $(".grid-question-table :radio").on("change", function(){
        var table = $(this).closest("table");
        var tr = $(this).closest("tr");
        var index = tr.find(":radio").index($(this));
          if($(this).find(":radio").eq(index).prop("checked") == true)
            $(this).find(":radio").prop("checked", false);

It is also possible to make the question optional (for example, you have 9 items but you want the respondent to mark a preference for the top 3): to do so, you can simply set the question as “optional” from the gearwheel button of the question itself.

Leave A Comment?