【问题标题】:Array of Checkboxes and input text fields in Limesurvey (2.0)Limesurvey (2.0) 中的复选框数组和输入文本字段
【发布时间】:2012-11-16 16:14:52
【问题描述】:

我想创建一个由复选框和短文本输入字段组成的数组问题。插图:

 Fruits      bitter    sweet    salty      other                
 orange       cBox     cBox     cBox     inputText
 mango        cBox     cBox     cBox     inputText
   .           .        .        .           .
   .           .        .        .           .
   .           .        .        .           .
inputText     cBox     cBox     cBox     inputText

到目前为止,我可以在 Checkbox 变体中创建一个“数组(Multi Flexi)(数字)”,但不能使用所需的文本输入字段。关于示例,用户应该能够输入一种新水果并用自己的口味进行描述。

似乎没有办法在 Limesurvey 2.0 中创建新的问题类型。但我找到了一个基于 JavaScript 的解决方法来安排several single questions in one line。在尝试修改此脚本时,我发现它不支持我需要的数组问题类型(前面提到过)。

有什么想法或不同的方法来解决这个啊,挑战? 非常感谢您提供帮助我解决此问题的任何帮助或技巧!

【问题讨论】:

    标签: javascript limesurvey


    【解决方案1】:

    替代方案:

    1. 使用“文本”数组(LimeSurvey 中的现有问题类型)
    2. 更新所需的“输入:文本”:在同一单元格中添加一个“输入:复选框”(jquery 在这里)
    3. 为每个复选框添加一个系统:选中此复选框时:将 input:text 设置为 Y,否则将 input:text 设置为空值

      <script>
      $(document).on('click',"#question{QID} :checkbox",function(){
          copiedid=$(this).data('copy');
          if($(this).is(':checked')){
              $("#"+copiedid).val('Y');
          }else{
              $("#"+copiedid).val('');
          }
      });
      $(document).ready(function(){
          $('#question{QID}  tbody tr td:not(:last-child)').each(function(){
              var textinputid=$(this).find('input:text').attr('id');
              $(this).find('input:text').hide();
              $(this).append("<input type='checkbox' data-copy='"+textinputid+"' />");
          });
      });
      </script>
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-30
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多