- Posts: 9
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How do you put sub code headings into a codeframe?
- benmok
- Topic Author
- Offline
- New Member
Less
More
10 years 10 months ago #96098
by benmok
How do you put sub code headings into a codeframe? was created by benmok
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!
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!
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
10 years 10 months ago #96143
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How do you put sub code headings into a codeframe?
You can insert those headings with JavaScript. Something like this in the question source:
Code:
<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.
The topic has been locked.
- benmok
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
10 years 10 months ago #96152
by benmok
Replied by benmok on topic How do you put sub code headings into a codeframe?
Hi thanks for your reply - Where do I put the J script? in the question type CSS?
Thanks,
Ben
Thanks,
Ben
The topic has been locked.
- benmok
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
10 years 10 months ago #96154
by benmok
Replied by benmok on topic How do you put sub code headings into a codeframe?
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
Many thanks.
Ben
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
10 years 10 months ago #96164
by tpartner
- 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:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How do you put sub code headings into a codeframe?
In the question source - manual.limesurvey.org/Workarounds:_Manip....29_in_LimeSurvey.3FWhere do I put the J script?
- For the first one, ".prepend" places it a the beginning of the list.Where do I set in the script the position of those sub headings
- 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:
Code:
$('.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.
The topic has been locked.
- benmok
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
10 years 10 months ago #96165
by benmok
Replied by benmok on topic How do you put sub code headings into a codeframe?
Thank you Tony you totally rock!
The topic has been locked.
- benmok
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
10 years 10 months ago #96166
by benmok
Replied by benmok on topic How do you put sub code headings into a codeframe?
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>
______________________________________________________________________________________________________
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>
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
10 years 10 months ago - 10 years 10 months ago #96168
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How do you put sub code headings into a codeframe?
Slightly different for multiple-choice:
Code:
<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.
Last edit: 10 years 10 months ago by tpartner.
The topic has been locked.
- benmok
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
10 years 10 months ago #96186
by benmok
Replied by benmok on topic How do you put sub code headings into a codeframe?
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.
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.
Attachments:
The topic has been locked.