Welcome to the LimeSurvey Community Forum

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

Multiple dropdown box within text

  • Anika___
  • Anika___'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago #202517 by Anika___
Multiple dropdown box within text was created by Anika___
Hey,

I need an item type where I can include multiple dropdown boxes within a text.

I am looking for solutions for two versions of this type:

Simple: Just one multiple dropdown box within one sentence.


This is what the (dropdown: item, anwers, dress, house) should look like.



Advanced: Various multiple drop-downboxes within one short text.

This (dropdown: item, ...) should look like this. It seems rather (dropdown: difficult, easy, boring, xy) to create.


I would appreciate any kind of help and ideas.

Cheers!
Anika

Limesurvey Version 2.67.3+170728
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #202536 by tpartner
Replied by tpartner on topic Multiple dropdown box within text
Simple:

1) Add a <span> element to the question source:
Code:
This <span class='inserted-dropdown'>&amp;nbsp;</span> should look like.

2) Add this script to the question source:
Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready',function(){
    var thisSelect = $('#question{QID} select[id^="answer"]:eq(0)');
 
    // Move the dropdown
    $('#question{QID} .inserted-dropdown:eq(0)').append(thisSelect);
  });
</script>


Advanced:

1) Add a second (or more) dropdown question directly after this question.

2) Add several <span> elements to the question source:
Code:
This is what the <span class='inserted-dropdown'>&amp;nbsp;</span>  should look like this. It seems rather <span class='inserted-dropdown'>&amp;nbsp;</span> to create.

3) Add this script to the question source:
Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready',function(){
    var thisSelect = $('#question{QID} select[id^="answer"]:eq(0)');
    var secondSelect = $('#question{QID}').nextAll('[id^="question"]:eq(0)').find('select[id^="answer"]:eq(0)');
 
    // Move the first dropdown
    $('#question{QID} .inserted-dropdown:eq(0)').append(thisSelect);
    // Move the second dropdown
    $('#question{QID} .inserted-dropdown:eq(1)').append(secondSelect );
 
    // Hide the next question
    $('#question{QID}').nextAll('[id^="question"]:eq(0)').hide();
  });
</script>



Sample survey attached:

File Attachment:

File Name: limesurvey...2282.lss
File Size:19 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Anika___
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #202540 by DenisChenu
Replied by DenisChenu on topic Multiple dropdown box within text
How a 2.6 version screenshot !

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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #202542 by tpartner
Replied by tpartner on topic Multiple dropdown box within text
Anika said "Limesurvey Version 2.67.3+170728", I missed one of the dots.

It should also work in 2.67.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu, Anika___
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #202547 by tpartner
Replied by tpartner on topic Multiple dropdown box within text
...it just needs a few styles in 2.73.0.

Code:
<style type="text/css">
  #question{QID} select {
    display: inline-block;
    margin: 0 0 0 -0.25em;
    width: auto;
    height: auto;
    padding: 0;
  }
 
  #question{QID} .answer-container{
    display: none;
  }
</style>


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Anika___
The topic has been locked.
  • Anika___
  • Anika___'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago #202562 by Anika___
Replied by Anika___ on topic Multiple dropdown box within text
Thank you, tpartner! This looks exactly like what I need!
I will try this later and let you know how it went!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #202563 by Joffm
Replied by Joffm on topic Multiple dropdown box within text
Just to confirm:

Works in 3.x, too.



Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: tpartner, Anika___
The topic has been locked.
  • Anika___
  • Anika___'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago - 3 years 9 months ago #202571 by Anika___
Replied by Anika___ on topic Multiple dropdown box within text
Dear all,

I have followed the advised steps.It works fine for the simple version, after I have added the styles tpartner posted for version 2.73.0. Than you!!



However, as you see in the screenshot, I do not get the second dropdown box in the advanced version. Below I am posting the script I added to the question source - it's just a copy paste from the ones suggested. What am I missing? I used the questiontype list (dropdown) for both versions...




Obviously I am not a very proficient user (yet:-) and would appreciate your help (again:-)!


Cheers, Anika

LimeSurvey Version 2.67.3 170728
Last edit: 3 years 9 months ago by Anika___. Reason: wrong screenshots
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago - 3 years 9 months ago #202578 by Joffm
Replied by Joffm on topic Multiple dropdown box within text
Hi,
the only way I can reproduce your screenshot is to set
"Always hide this question" in "Q3" to "ON"
"Hide tip" in "Q2" to "OFF"


But I cannot imagine that you did this.
You must not hide this question, because you need it - as you see.
And if you have a look at the javascript (I think this is understandable even without knowledge) there is this line
Code:
// Hide the next question
    $('#question{QID}').nextAll('[id^="question"]:eq(0)').hide();
Here the second dropdown question "Q3" is hidden.

Conclusion:
In all questions
"Hide tip" = "ON"
"Always hide this question" = "OFF

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 9 months ago by Joffm.
The following user(s) said Thank You: Anika___
The topic has been locked.
  • Anika___
  • Anika___'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago #202646 by Anika___
Replied by Anika___ on topic Multiple dropdown box within text
Thank you for your help and hints, Joffm!

I tried and retried now, but I can not get the second drop-down element visible, even if I set:
"hide tip"=ON
"always hide this question"= OFF

As you see in the screenshot below, I just get a space in the second sentence where the dropdown element is supposed to be sitting:-(


I have the feeling that I am missing something very basic; maybe something that is clear to everyone but I do not see it. I will share in detail what I did to get this result for the advanced version (multiple drowdown within a short text), maybe someone can spot something from the outside or advise me on what to do or what to consider:

1. I add ONE new question, choosing the type list (dropdown)
2. I copy paste the codes by tpartner for the advanced version (including the styles) into the question source. I did not make any changes to the code.
3. I put "hide tip"= ON and "always hide this question"= OFF

4. I save and preview and get the screenshot posted above, i.e. without the second dropdown element:-(

Is there anything mixed up? Or any general or specific setting I am not taking into account? Any ideas....? ...would be hugely appreciated:-)

CheersAnika
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #202657 by tpartner
Replied by tpartner on topic Multiple dropdown box within text
Well, for that you will need two dropdown questions. Where is the second dropdown supposed to come from?

What happens with my sample survey?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu, Anika___
The topic has been locked.
  • Anika___
  • Anika___'s Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago #202665 by Anika___
Replied by Anika___ on topic Multiple dropdown box within text
yeah right, good question:-)
I added another question and *magic*, it worked. Sometimes reading carefully clearly helps!

(That's what I mean with missing something very basic...:-)))

Anyway: Thanks a lot for your patience!! Great!!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose