Welcome to the LimeSurvey Community Forum

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

Array (text) type question with customized drop down in specific columns

  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 5 months ago - 1 year 5 months ago #245418 by tpartner
The problem is your LimeSurvey version is too old. ExpressionScript is not triggered by the change event in that obsolete version.

I am responding from a mobile device so cannot test but my guess is you need to fire the checkconditions() event in the listener for the dropdowns.

Try changing this line:
Code:
$('input:text', thisCell).val(newValue).trigger('change');

To this:
Code:
$('input:text', thisCell).val(newValue);
checkconditions(newValue, $('input:text:eq(0)', thisCell).attr('name'), 'text');

 

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 1 year 5 months ago by tpartner.
The following user(s) said Thank You: MC_EMC

Please Log in to join the conversation.

More
1 year 5 months ago #245420 by MC_EMC
I believe so...
It works right now with the new code.


Thank you again for the help!

Please Log in to join the conversation.

More
1 year 4 months ago #246123 by AntPIC
can I create Array (text) type question with customized drop down in specific columns through expression manager?

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 4 months ago - 1 year 4 months ago #246124 by Joffm
WHY DO YOU NEVER MENTION YOUR VERSION?
This thread was about version 2.06.

With a small javascript snippet, like  ("X00x" = codes of x-axis)
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    var thisQuestion = $('#question{QID}');
 
    // Insert selects
    $('.answer-item.answer_cell_X002', thisQuestion).addClass('with-select').append('<select name="select1" class="inserted-select form-control list-question-select">\
              <option value="">...</option>\
            <option value="1">Fußball</option>\
            <option value="2">Handball</option>\
            <option value="3">Karate</option>\
            <option value="4">Leichtathletik</option>\
            <option value="5">Schwimmen</option>\
            <option value="6">Volleyball</option>\
    </select>');  
    $('select[name="select1"] option[value="2"]').attr('selected','selected');
    $('.answer-item.answer_cell_X003', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
  <option value="">...</option>\
            <option value="1">U8 (2014 und jünger)</option>\
            <option value="2">U10 (2012-2013)</option>\
            <option value="3">U12 (2010-2011)</option>\
            <option value="4">U14 (2008-2009)</option>\
            <option value="5">U16 (2006-2007)</option>\
            <option value="6" selected>U18 (2004-2005)</option>\
    </select>');
 
    // Listeners
    $('.inserted-select', thisQuestion).on('change', function(i) {
      if($(this).val() != '') {
        $(this).closest('.answer-item').find('input:text').val($('option:selected', this).val()).trigger('change');
      }
      else {
        $(this).closest('.answer-item').find('input:text').val('').trigger('change');
      }
    });
 
  // Returning to page
    $('.with-select input:text', thisQuestion).each(function(i) {
      var thisCell = $(this).closest('.answer-item');
      var inputText = $.trim($(this).val());
      $('select.inserted-select', thisCell).val(inputText);
    });
 
    // Clean-up styles
    $('select.inserted-select', thisQuestion).css({
      'max-width': '100%'
    });
    $('.with-select input:text', thisQuestion).css({
      'position': 'absolute',
      'left': '-9999em'
    });
  });
</script>
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 4 months ago by Joffm.

Please Log in to join the conversation.

More
1 year 4 months ago #246125 by AntPIC
Sorry my version is
LimeSurvey Cloud
Versione 5.6.31

Is there a way through expression manager?

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 4 months ago #246128 by Joffm
No.
How do you imagine to insert a "select" element into a text field by ExpressionScript?

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose