Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

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

Use separator as the category drop-down list of questions 5 years 1 week ago #69957

  • mattias01
  • mattias01's Avatar
  • Offline
  • Senior Lime
  • Posts: 79
  • Karma: 1
eg

America
Chile
ARENTINO

Europe
France
Spain

I did the following but did not work.



I hope to help

regards
The administrator has disabled public write access.

Use separator as the category drop-down list of questions 5 years 1 week ago #69958

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5432
  • Thank you received: 811
  • Karma: 240
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 | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

Use separator as the category drop-down list of questions 5 years 1 week ago #69959

  • mattias01
  • mattias01's Avatar
  • Offline
  • Senior Lime
  • Posts: 79
  • Karma: 1
thank you very much for answering.

regards
The administrator has disabled public write access.

Use separator as the category drop-down list of questions 5 years 1 week ago #69996

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6571
  • Thank you received: 1477
  • Karma: 579
You can use JavaScript to insert <optgroup> tags in the dropdown:


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


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.
The administrator has disabled public write access.

Use separator as the category drop-down list of questions 5 years 1 week ago #70001

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6029
  • Thank you received: 373
  • Karma: 260
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...ator.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)survey-consulting.com'"
The administrator has disabled public write access.

Use separator as the category drop-down list of questions 5 years 1 week ago #70005

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

regards
The administrator has disabled public write access.

Use separator as the category drop-down list of questions 5 years 1 week ago #70006

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6571
  • Thank you received: 1477
  • Karma: 579
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.
The administrator has disabled public write access.

Use separator as the category drop-down list of questions 5 years 1 week ago #70066

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6029
  • Thank you received: 373
  • Karma: 260
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)survey-consulting.com'"
The administrator has disabled public write access.
Time to create page: 0.269 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form