Welcome to the LimeSurvey Community Forum

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

Pulldown menu responses not visible

  • hemler
  • hemler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 1 month ago #241156 by hemler
Pulldown menu responses not visible was created by hemler
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.6.7+230222
Own server or LimeSurvey hosting: UNIGE
Survey theme/template: User Perceptions Questionnaire
==================
I placed a question in my survey asking people how much they would be willing to pay for a product. I used the code below to have one dropdown menu with different types of currencies and the second part was a free-response where the participant could fill in the amount. 
When I exported the answer from ~100 responses, there was data for the amount, but not the currency and I can't seem to do anything to find this important currency data from the pulldown menu. Any tips of how to find the data? (The survey is still open)

<script type="text/javascript" charset="utf-8">        
 
    $(document).ready(function(){    
 
        // Identify this question
        var thisQuestion = $('#question{QID}');
 
        // Assign column-specific classes
        $('table.subquestion-list tr', thisQuestion).each(function(i) {
 
            $('> *:gt(0)', this).each(function(i){
                $(this).addClass('column-'+(i+1));
                $(this).attr('data-column', i+1);
            });
        });
 
        // Hide the text inputs
        $('.answer-item.column-1 input[type="text"]').hide();
 
        // Define the select element (dropdown)
        var select1 = '<select class="inserted-select"> \
                            <option value="">-- Please Choose --</option> \
                            <option value="USD">USD</option> \
                            <option value="EUR">EUR</option> \
                            <option value="GBP">GBP</option> \
                            <option value="CHF">CHF</option> \
                            <option value="AUD">AUD</option> \
                            <option value="JPY">JPY</option> \
                            <option value="CAD">CAD</option> \
                            <option value="NOK">NOK</option> \
                            <option value="SEK">SEK</option> \
                            </select>';
 
        // Insert the select elements into column 2
        $('.answer-item.column-1').append(select1);
 
        // Initial dropdown values in column  (if the question has already been answered)
        $('.answer-item.column-2 input[type="num"]').each(function(i){
            if($.trim($(this).val()) != '') {
                $(this).closest('td').find('.inserted-select').val($.trim($(this).val()));
            }
        });
 
        // Listener on the dropdowns (insert selected values into hidden text input)
          $('.answer-item.column-2 input:text', thisQuestion).on('keyup change', function(e) {
            var thisValue = $.trim($(this).val());
 
            // Strip out non-numerics characters
            newValue = thisValue.replace(/\D/g,'').replace(/,/g,'').replace(/\./g,'');
            $(this).val(newValue).trigger('change');
        
        });
    });
</script>

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241157 by Joffm
Replied by Joffm on topic Pulldown menu responses not visible
Please, provide a lss export.
You did not mention which question type you are using.
Array(text), multiple text, or?

Joffm 

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

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241158 by tpartner
Replied by tpartner on topic Pulldown menu responses not visible
Where did that code come from? It makes reference to both columns 1 and 2 and appears to insert dropdowns in column 1 but there is no listener on those dropdowns to load the selection into the hidden text input.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241163 by Joffm
Replied by Joffm on topic Pulldown menu responses not visible
Hi,
I tried to find the script, but did not.
Where did you find it?
I am really confused about an "input[type="num"]


Anyway:
With an array (what you seem to be using) and this script
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
    var thisQuestion = $('#question{QID}');
 
    // Column-specific classes
    $('tr.subquestion-list', thisQuestion).each(function(i) {
      $('th, td', this).each(function(i) {
        $(this).addClass('column-'+i);
      });
    });
 
    // Insert selects into column 1
    if($('.answer-item.column-1 .inserted-select', thisQuestion).length == 0) {
      $('.answer-item.column-1', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
        <option value="">Please choose...</option>\
                            <option value="USD">USD</option> \
                            <option value="EUR">EUR</option> \
                            <option value="GBP">GBP</option> \
                            <option value="CHF">CHF</option> \
                            <option value="AUD">AUD</option> \
                            <option value="JPY">JPY</option> \
                            <option value="CAD">CAD</option> \
                            <option value="NOK">NOK</option> \
                            <option value="SEK">SEK</option> \
      </select>');
    }
 
    // Listeners on select elements
    $('.inserted-select', thisQuestion).on('change', function(i) {
      if($(this).val() != '') {
        $(this).closest('.answer-item').find('input:text').val($.trim($('option:selected', this).text())).trigger('change');
      }
      else {
        $(this).closest('.answer-item').find('input:text').val('').trigger('change');
      }
    });
 
    // Listener on column 2 inputs
    $('.answer-item.column-2 input:text', thisQuestion).on('keyup change', function(e) {
      var thisValue = $.trim($(this).val());
 
      // Numerics only
      if($.isNumeric(thisValue) === false) {
 
        // Strip out non-numerics characters
        newValue = thisValue.replace(/\D/g,'');
        $(this).val(newValue).trigger('change');
      }
    });
 
    // Returning to page
    $('.with-select input:text', thisQuestion).each(function(i) {
      var thisCell = $(this).closest('.answer-item');
      var inputText = $.trim($(this).val());
      var selectval = $('select.inserted-select option', thisCell).filter(function () { return $(this).html() == inputText; }).val();
      $('select.inserted-select', thisCell).val(selectval);
    });
 
 
    // Clean-up styles
    $('select.inserted-select', thisQuestion).css({
      'max-width': '100%'
    });
    $('.with-select input:text', thisQuestion).css({
      'position': 'absolute',
      'left': '-9999em'
    });
});
</script>

or a "mutlple short text" question and this script
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:complete',function()    {
    var qID = {QID};
    var inputNum = 1;
 
    // Define the select element (dropdown)
    var prov1 = '<select id="prov1" class="form-control">\
          <option value="">Please choose...</option>\
                            <option value="USD">USD</option> \
                            <option value="EUR">EUR</option> \
                            <option value="GBP">GBP</option> \
                            <option value="CHF">CHF</option> \
                            <option value="AUD">AUD</option> \
                            <option value="JPY">JPY</option> \
                            <option value="CAD">CAD</option> \
                            <option value="NOK">NOK</option> \
                            <option value="SEK">SEK</option> \
          </select>';
         // Hide the text input
    $('#question'+qID+' .question-item:eq('+(inputNum-1)+') input[type="text"]').hide();
 
    // Insert the select elements
    if($('#question'+qID+' .question-item:eq('+(inputNum-1)+') select').length == 0) {
      $('#question'+qID+' .question-item:eq('+(inputNum-1)+') input[type="text"]').before(prov1);
    }
 
    // Initially select an option if the question has already been answered
    $('#question'+qID+' select').each(function(i) {
      if($.trim($(this).next('input[type="text"]').val()) != '') {
        $(this).val($.trim($(this).next('input[type="text"]').val()));
      }
    });
 
    // Listener on the dropdowns - insert selected values into hidden text input
    $('#question'+qID+' select').change(function() {
      var thisInput = $(this).next('input[type="text"]');
      $(thisInput).val($(this).val());
      checkconditions($(thisInput).attr('value'), $(thisInput).attr('name'), 'text');
    });
 
    // Some styles
    $('#question'+qID+' select').css({
    'margin':'0.3em 0 0 0'
    });
  });
</script>

I get this
 

 

and everything is stored.
 





 

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

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241172 by holch
Replied by holch on topic Pulldown menu responses not visible
So you did not test this before it went into field?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • hemler
  • hemler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 1 month ago #241180 by hemler
Replied by hemler on topic Pulldown menu responses not visible
Thanks for the scripts! I'll use the array(text) one to fix the script as that was the question type.

So, with the script that I did have, do you think there is any way to salvage the data?...

Please Log in to join the conversation.

  • hemler
  • hemler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 1 month ago #241181 by hemler
Replied by hemler on topic Pulldown menu responses not visible
I must have missed checking this specific question...the others ones were all fine. A lesson learned for next time.

Please Log in to join the conversation.

  • hemler
  • hemler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 1 month ago #241182 by hemler
Replied by hemler on topic Pulldown menu responses not visible
So I tried to use the script you wrote, but when trying out the question, it only allowed me to see the currency dropdown and not the free response question. Any suggestions? Could it be a version problem or something else?

 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago - 1 year 1 month ago #241185 by Joffm
Replied by Joffm on topic Pulldown menu responses not visible
Obviously you havbe only one column

Send the lss export of this question.

Joffm

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

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241186 by tpartner
Replied by tpartner on topic Pulldown menu responses not visible
No, there is no data.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • hemler
  • hemler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 1 month ago #241187 by hemler
Replied by hemler on topic Pulldown menu responses not visible
I created a new survey with just one question with the code you sent. It should have the same settings as the question in the live survey.

See the .lss for this new survey. Thanks for your help!
 

File Attachment:

File Name: limesurvey...6141.lss
File Size:24 KB

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241188 by Joffm
Replied by Joffm on topic Pulldown menu responses not visible
Hm,
what do you expect if there are no x-axis subquestions?
 

Enter subquestions and everything is fine
 



Or you add subquestions with only a blank as text.
 

Joffm

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

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose