Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Random Brand selection for Multi Choice

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 6 months ago #220506 by Joffm
Replied by Joffm on topic Random Brand selection for Multi Choice
And there is a solution without "installing" the plugin.

As you might have seen, the php-file only registers the js-file and the css-file.
Code:
        $oEvent = $this->event;
        $iSurveyId = $oEvent->get('surveyId');
        $assetUrl = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets');
        Yii::app()->clientScript->registerScriptFile($assetUrl . '/hideemptycolumn.js',CClientScript::POS_END);
        Yii::app()->clientScript->registerCssFile($assetUrl . '/hideemptycolumn.css');
 

So you can insert the code of these files directly into your question (in source code mode) or your theme (custom.js, custom.css).
Like:
Code:
<script>
$(document).on('ready pjax:scriptcomplete',function(){
$("table.question,table.ls-answers").each(function(){
    var basetable=$(this);
    basetable.find('col.odd,col.even,col.ls-col-odd,col.ls-col-even').addClass('havewidth');
    $(this).find("thead tr:last-child th").each(function(){
        if($.trim($(this).html())==""){
            if(basetable.find('col.havewidth').length){
                basetable.find('col.havewidth').removeAttr('width').removeClass('havewidth');
            }
            var colindex=$(this).parent('tr').find('td,th').index($(this));
            basetable.find('col').eq(colindex).css('width',0);
            basetable.find('col').eq(colindex).width(0);
            basetable.find('tr').each(function(){
                $(this).find('td,th').eq(colindex).addClass('hideEmptyColumn-hiddencolumn').children().hide();
            });
            basetable.addClass('hideEmptyColumn-widthhiddencolumn');
        }
    });
});
});
</script>

and 
Code:
<style type="text/css">td.hideEmptyColumn-hiddencolumn,th.hideEmptyColumn-hiddencolumn{
    overflow:hidden !important;
    border-spacing:0 !important;
    border-collapse:collapse !important;
    padding:0 !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
}
td.hideEmptyColumn-hiddencolumn *,th.hideEmptyColumn-hiddencolumn * {
    display:none;
}
table.ls-answers > tbody > tr > td.hideEmptyColumn-hiddencolumn{border-collapse:collapse !important;}
table.hideEmptyColumn-widthhiddencolumn{
    border-collapse:collapse !important;
}
</style>

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • scene143
  • scene143's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 6 months ago #220510 by scene143
Replied by scene143 on topic Random Brand selection for Multi Choice
Thank you very much Joffm ...
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 6 months ago #220522 by DenisChenu
Replied by DenisChenu on topic Random Brand selection for Multi Choice
Yep,Still need to create a plugin with question settings for this 

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose