Welcome to the LimeSurvey Community Forum

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

Entering Numbers & a dropdown for currency

  • StefanBasen
  • StefanBasen's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 5 months ago #143259 by StefanBasen
Entering Numbers & a dropdown for currency was created by StefanBasen
Hello everyone :)

i got a tough Mission here ( for me ), but maybe someone can help me out on this.

what i need is, that there are 2 Fields where they can enter Numbers and right next to it a dropdown where they can select their currency ( EUR/USD )

Als Example:

"Field for the numbers" - [Dropdown currency]
"Field for the Numbers" - [Dropdown currency]

Any Idea how to get it that way?

Thank you very much :)
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #143263 by Joffm
Replied by Joffm on topic Entering Numbers & a dropdown for currency
Hi, Stefan,

I think this will help.
www.limesurvey.org/de/foren/can-i-do-thi...n-col2-,-slider-col3

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • StefanBasen
  • StefanBasen's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 5 months ago #143266 by StefanBasen
Replied by StefanBasen on topic Entering Numbers & a dropdown for currency
Thank you for your response, but sadly it doesnt work for me. Tried the Code and to remove the Slider ( wich i dont need ) but sadly it doesnt work :( its the right thing and i tried it On my Matrix ( Text )

I have added a Picture to show what i mean. So the last row ( Currency) should be a Dropdown wich Contains 2 Options: EUR & USD
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #143275 by tpartner
Replied by tpartner on topic Entering Numbers & a dropdown for currency
StefanBasen, paste the code that you used here.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • StefanBasen
  • StefanBasen's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 5 months ago #143277 by StefanBasen
Replied by StefanBasen on topic Entering Numbers & a dropdown for currency
This is the Code i tried to use. Modified it a bit ( removed the Slider that was in it before and changed the Column from 3 to 2 )
Code:
<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);
      });
    });
 
 
    // Define the select element (dropdown)
    var select1 = '<select class="inserted-select"> \
              <option value="">-- Please Choose --</option> \
              <option value="EUR">Program 1</option> \
              <option value="USD">Program 2</option> \
              </select>';
 
    // Insert the select elements into column 2
    $('.answer-item.column-2').append(select1);
 
    // Initial dropdown values in column  (if the question has already been answered)
    $('.answer-item.column-2 input[type="text"]').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)
    $('.inserted-select').change(function() {
      $(this).closest('td').find('input[type="text"]').val($(this).val());
    });
 
 
 
  });
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #143280 by tpartner
Replied by tpartner on topic Entering Numbers & a dropdown for currency
Well, it looks okay to me except you forgot to hide the text inputs in column 2 (see script below).

Do you have any JS errors?

Code:
<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-2 input[type="text"]').hide();
 
    // Define the select element (dropdown)
    var select1 = '<select class="inserted-select"> \
              <option value="">-- Please Choose --</option> \
              <option value="EUR">EUR</option> \
              <option value="USD">USD</option> \
              </select>';
 
    // Insert the select elements into column 2
    $('.answer-item.column-2').append(select1);
 
    // Initial dropdown values in column  (if the question has already been answered)
    $('.answer-item.column-2 input[type="text"]').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)
    $('.inserted-select').change(function() {
      $(this).closest('td').find('input[type="text"]').val($(this).val());
    });
  });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...9762.lss
File Size:18 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose