Bienvenue, Invité
Nom d'utilisateur : Mot de passe : Se souvenir de moi

SUJET : How do you put sub code headings into a codeframe?

How do you put sub code headings into a codeframe? il y a 1 an 6 mois #96098

  • benmok
  • Portrait de benmok
  • Hors ligne
  • Fresh Lemon
  • Messages : 10
  • Karma: 0
This is what I am trying to achieve.....

RESTAURANT:
Cleanliness of restaurant
Design of restaurant
Restaurant ambience

PRODUCT:
Price of food
Portion of food
Presentation of food

I want to be able to display the category headings in a radio list or multiple choice question.

Thanks!
L'administrateur a désactivé l'accès en écriture pour le public.

How do you put sub code headings into a codeframe? il y a 1 an 6 mois #96143

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 4371
  • Remerciements reçus 829
  • Karma: 381
You can insert those headings with JavaScript. Something like this in the question source:
<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
		var qID = {QID};
		var q1 = $('#question'+qID+'');
 
		// Insert some items in the list
		$('.answers-list', q1).prepend('<li>RESTAURANT:</li>');
		$('.answers-list li:eq(3)', q1).after('<li style="padding-top:1em;">PRODUCT:</li>');
	});
</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.
L'administrateur a désactivé l'accès en écriture pour le public.

How do you put sub code headings into a codeframe? il y a 1 an 6 mois #96152

  • benmok
  • Portrait de benmok
  • Hors ligne
  • Fresh Lemon
  • Messages : 10
  • Karma: 0
Hi thanks for your reply - Where do I put the J script? in the question type CSS?

Thanks,
Ben
L'administrateur a désactivé l'accès en écriture pour le public.

How do you put sub code headings into a codeframe? il y a 1 an 6 mois #96154

  • benmok
  • Portrait de benmok
  • Hors ligne
  • Fresh Lemon
  • Messages : 10
  • Karma: 0
Hi - I also apologize for not being very technical savvy. Where do I set in the script the position of those sub headings
Many thanks.
Ben
L'administrateur a désactivé l'accès en écriture pour le public.

How do you put sub code headings into a codeframe? il y a 1 an 6 mois #96164

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 4371
  • Remerciements reçus 829
  • Karma: 381
Where do I put the J script?
In the question source - manual.limesurvey.org/Workarounds:_Manip....29_in_LimeSurvey.3F

Where do I set in the script the position of those sub headings
- For the first one, ".prepend" places it a the beginning of the list.
- For the second, the "3" places it after the fourth list item (indexes of list items start a 0). So, for example, if you wanted it after the sixth item, you would use:
$('.answers-list li:eq(5)', q1).after('<li style="padding-top:1em;">NEW CATEGORY:</li>');
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.
L'administrateur a désactivé l'accès en écriture pour le public.

How do you put sub code headings into a codeframe? il y a 1 an 6 mois #96165

  • benmok
  • Portrait de benmok
  • Hors ligne
  • Fresh Lemon
  • Messages : 10
  • Karma: 0
Thank you Tony you totally rock!
L'administrateur a désactivé l'accès en écriture pour le public.

How do you put sub code headings into a codeframe? il y a 1 an 6 mois #96166

  • benmok
  • Portrait de benmok
  • Hors ligne
  • Fresh Lemon
  • Messages : 10
  • Karma: 0
Not sure what i have done wrong here but the subheadings are not showing up.....i have inserted the following into the source. Oh btw i am using a multiple choice with comment question type not sure if that makes any difference in terms of source codes. Thanks Ben
______________________________________________________________________________________________________

You have rated your overall dining experience at our restaurant as<span style="color:#0000ff;"> {INSERTANS:817666X1514X26751}</span>. Please categorise your reason(s) below and provide comments in the corresponding comment box.

<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
var qID = {QID};
var NPSreason = $('#question'+qID+'');

// Insert some items in the list
$('.answers-list', NPSreason).prepend('<li>CUSTOMER SERVICE PERSON:</li>');
$('.answers-list li:eq(4)', NPSreason).after('<li style="padding-top:1em;">RESTAURANT:</li>');
$('.answers-list li:eq(9)', NPSreason).after('<li style="padding-top:1em;">PRODUCT:</li>');
});
</script>
L'administrateur a désactivé l'accès en écriture pour le public.

How do you put sub code headings into a codeframe? il y a 1 an 6 mois #96168

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 4371
  • Remerciements reçus 829
  • Karma: 381
Slightly different for multiple-choice:
<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
		var qID = {QID};
		var NPSreason = $('#question'+qID+'');
 
		// Insert some items in the list
		$('.subquestions-list', NPSreason).prepend('<li>CUSTOMER SERVICE PERSON:</li>');
		$('.subquestions-list li:eq(4)', NPSreason).after('<li style="padding-top:1em;">RESTAURANT:</li>');
		$('.subquestions-list li:eq(9)', NPSreason).after('<li style="padding-top:1em;">PRODUCT:</li>');
	});
</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.
Dernière édition: il y a 1 an 6 mois par tpartner.
L'administrateur a désactivé l'accès en écriture pour le public.

How do you put sub code headings into a codeframe? il y a 1 an 6 mois #96186

  • benmok
  • Portrait de benmok
  • Hors ligne
  • Fresh Lemon
  • Messages : 10
  • Karma: 0
Thanks Tony that work beautifully!

While I have you here if you don't mind me asking 2 more questions.

1) Is there a way to only activate those comment fields for the selected multiple response codes?

2) Is there a way to make the comment field mandatory?

Please see attached image.
Pièces jointes :
L'administrateur a désactivé l'accès en écriture pour le public.
Modérateurs: ITEd
Temps de génération de la page : 0.153 secondes
Donation Image