Welcome, Guest
Username: Password: Remember me

TOPIC: Use separator as the category drop-down list of questions

Use separator as the category drop-down list of questions 2 years 8 months ago #69957

  • mattias
  • mattias's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 77
  • Karma: 1
eg

America
Chile
ARENTINO

Europe
France
Spain

I did the following but did not work.
pantalla.png



I hope to help

regards
The administrator has disabled public write access.

Re: Use separator as the category drop-down list of questions 2 years 8 months ago #69958

  • holch
  • holch's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 2569
  • Thank you received: 291
  • Karma: 106
In the field "separador de categorias" you only insert the symbol that you want to be the separator.

Let's assume you want "|" to be the separator, then you include this.

Then the subquestions have to have the following format:

America|Argentina
America|Chile
America|USA
America|Canada
Europe|France
Europe|Spain
Europe|Germany

However, this is pretty well documented in the manual.
docs.limesurvey.org/Advanced+question+se...y#category_separator
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Re: Use separator as the category drop-down list of questions 2 years 8 months ago #69959

  • mattias
  • mattias's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 77
  • Karma: 1
thank you very much for answering.

regards
The administrator has disabled public write access.

Re: Use separator as the category drop-down list of questions 2 years 8 months ago #69996

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4071
  • Thank you received: 748
  • Karma: 341
You can use JavaScript to insert <optgroup> tags in the dropdown:
dropdown_1.gif


1) Add prepend the answers with group-specific values:
answers_1.gif


2) Add the following code to the source of your question. Replace "QQ" with the question ID.

The script will wrap all answers with codes that start with "eu" in an optgroup with label "Europe" and those with codes that start with "am" in an optgroup with label "America".
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var qID = QQ;
 
		// Add group-specific classes to the dropdown options
		$('#question'+qID+' option').each(function(i){
			var myClass = $(this).attr('value').substr(0, 2);
			$(this).addClass(myClass);
		});
 
		// Wrap the options in <optgroup> tags
		$('option.am').wrapAll('<optgroup label="America" />');
		$('option.eu').wrapAll('<optgroup label="Europe" />');
	});
 
</script>
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Use separator as the category drop-down list of questions 2 years 8 months ago #70001

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5302
  • Thank you received: 291
  • Karma: 247
Attached is a sample question which you can import when creating a new question. It shows how the separator can be used.

File Attachment:

File Name: limesurvey_question_422_dropdown_separator.lsq
File Size: 12 KB



@Tony, I know one can do nearly everything with JS but for such cases the question attribute was implemented :-)

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Use separator as the category drop-down list of questions 2 years 8 months ago #70005

  • mattias
  • mattias's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 77
  • Karma: 1
3 thank you very much for all the examples I have worked ok.

regards
The administrator has disabled public write access.

Re: Use separator as the category drop-down list of questions 2 years 8 months ago #70006

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4071
  • Thank you received: 748
  • Karma: 341
Ah, maybe that advanced setting should be renamed to what it actually is/does - "Option Groups Separator" - and the wiki updated,
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Use separator as the category drop-down list of questions 2 years 8 months ago #70066

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5302
  • Thank you received: 291
  • Karma: 247
Sure, go ahead :-)

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.130 seconds
Donation Image