Multiple dropdown box within text

More
1 month 3 days ago #202517 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

Please Log in to join the conversation.

LimeSurvey Partners
More
1 month 3 days ago #202536 by tpartner
Simple:

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

2) Add this script to the question source:
<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:
This is what the <span class='inserted-dropdown'>&nbsp;</span>  should look like this. It seems rather <span class='inserted-dropdown'>&nbsp;</span> to create.

3) Add this script to the question source:
<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.
Official LimeSurvey Partner - partnersurveys.com
Attachments:
The following user(s) said Thank You: Anika___

Please Log in to join the conversation.

More
1 month 3 days ago #202540 by DenisChenu
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.

Please Log in to join the conversation.

More
1 month 3 days ago #202542 by tpartner
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.
Official LimeSurvey Partner - partnersurveys.com
The following user(s) said Thank You: DenisChenu, Anika___

Please Log in to join the conversation.

More
1 month 3 days ago #202547 by tpartner
...it just needs a few styles in 2.73.0.

<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.
Official LimeSurvey Partner - partnersurveys.com
Attachments:
The following user(s) said Thank You: Anika___

Please Log in to join the conversation.

More
1 month 3 days ago #202562 by Anika___
Thank you, tpartner! This looks exactly like what I need!
I will try this later and let you know how it went!

Please Log in to join the conversation.

More
1 month 3 days ago #202563 by Joffm
Just to confirm:

Works in 3.x, too.



Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: tpartner, Anika___

Please Log in to join the conversation.

More
1 month 2 days ago - 1 month 2 days ago #202571 by Anika___
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
Attachments:
Last edit: 1 month 2 days ago by Anika___. Reason: wrong screenshots

Please Log in to join the conversation.

More
1 month 2 days ago - 1 month 2 days ago #202578 by Joffm
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
// 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
Attachments:
Last edit: 1 month 2 days ago by Joffm.
The following user(s) said Thank You: Anika___

Please Log in to join the conversation.

More
4 weeks 2 days ago #202646 by Anika___
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
Attachments:

Please Log in to join the conversation.

More
4 weeks 2 days ago #202657 by tpartner
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.
Official LimeSurvey Partner - partnersurveys.com
The following user(s) said Thank You: DenisChenu, Anika___

Please Log in to join the conversation.

More
4 weeks 2 days ago #202665 by Anika___
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!!

Please Log in to join the conversation.

More
4 weeks 2 days ago #202672 by Joffm
And you show, that you did not import the sample that tpartner provided.
Otherwise you would have seen how it works.

If you do not do this, it is really difficult for us to help as we expect that you use and study the provided example.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu, Anika___

Please Log in to join the conversation.

More
4 weeks 2 days ago #202688 by Anika___
You are so right!
I did not even realise that tpartner sent a sample survey - I only saw the lss.file now and imported it. Great!
sorry for making your life difficult, I am still at a stage were I only see the explicit - it will get better, I am sure:-)

Cheers,
Anika

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now