Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:
  • Page:
  • 1
  • 2

TOPIC: titles between subquestions of the same array

titles between subquestions of the same array 4 years 7 months ago #70373

  • renu81072
  • renu81072's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
Can you let me know what will the whole code be like. Since I would want one line without radio button.. next few lines will should have radio button.. again in between a sub-heading and so on. If you could share with me the full code for this, would appreciate.

Am using the latest limesurvey... Am using Array option
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70374

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6129
  • Thank you received: 1360
  • Karma: 535
Rather than hide radios of sub-questions, I would use JavaScript to insert new rows with the sub-titles.

The following example workaround will insert new rows at positions 1, 3 and 6 as in the image below.

1) Set up your survey to use JavaScript.

2) Add the following script to the source of the array. Replace "QQ" with the array question ID and adjust the row numbers and subtitles as necessary.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// Call the function to insert sub-titles
		// Parameters (Question ID, Row number, Sub-title)
		insertSubTitle(QQ, 1, 'Group 1');
		insertSubTitle(QQ, 3, 'Group 2');
		insertSubTitle(QQ, 6, 'Group 3');
 
		// A function to insert sub-title rows in an array
		function insertSubTitle(qID, row, subtitle) {
 
			// Add some row-specific classes
			$('#question'+qID+' table.question tbody[id^="javatbd"]').each(function(i, el){
				$(el).addClass('ansRow-'+(i+1));
			});
 
			// Find number of columns
			var cols = $('#question'+qID+' table.question tbody[id^="javatbd"]:first tr:first > *').length;
 
			// Define the row to be inserted
			var insertedRow = '<tbody> \
									<tr class="insertedRow"> \
										<td colspan="'+cols+'">'+subtitle+'</td> \
									</tr> \
								</tbody>';
 
			// And insert the row
			$(insertedRow).insertBefore('#question'+qID+' .ansRow-'+row+'');
 
			// Fix up the row background colours
			var rowIndex = 0;
			$('#question'+qID+' table.question tr').each(function(i, el){
				rowIndex ++;
				if($(el).hasClass('insertedRow')) {
					rowIndex = 0;
				}
 
				$(el).removeClass('array1, array2');
 
				if(rowIndex % 2 == 0) {
					$(el).addClass('array1');
				}
				else {
					$(el).addClass('array2');
				}
			});
		}
 
	});
 
</script>

3) Add the following rules to the end of your template.css file:
.insertedRow {
	background-color: #66CCCC;
	font-weight: bold;
}
 
.insertedRow td {
	text-align: left !important;
}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 4 years 7 months ago by tpartner.
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70380

  • renu81072
  • renu81072's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
Hi: Have included the javascript while creating the array question. i.e., have inserted after the text what needs to get displayed in the source... Also the other code in the template.css file... but am attaching as to how it looks after have done all these changes...

Am using 1.91+ version

Regards
Renu
Attachments:
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70382

  • renu81072
  • renu81072's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
have replaced QQ with the QuestionID... even then its the same ... :( :(
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70383

  • DenisChenu
  • DenisChenu's Avatar
  • Online
  • Moderator Lime
  • Posts: 9284
  • Thank you received: 1324
  • Karma: 384
tpartner wrote: Look at this part:
Go to Global settings --> Security and set "Filter HTML for XSS" to "Off".

:)
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70384

  • renu81072
  • renu81072's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
Hi.. Now the code does not get displayed.. Thanks.. But still as seen in your image of array1 question, the grouping is not happening.. :(

Have added this code in the template.css
.insertedRow { background-color: #66CCCC; font-weight: bold;} .insertedRow td { text-align: left !important;}

The other code in source... but still the grouping is not happening.. :(
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70385

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6129
  • Thank you received: 1360
  • Karma: 535
Can you activate a sample survey for me to see?
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.

titles between subquestions of the same array 4 years 7 months ago #70386

  • renu81072
  • renu81072's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70387

  • renu81072
  • renu81072's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70388

  • renu81072
  • renu81072's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
Am online as of now.. Can we chat ??
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70389

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6129
  • Thank you received: 1360
  • Karma: 535
There are many line breaks missing in the script in your survey. Try copying and pasting it in again directly from the post above.
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.

titles between subquestions of the same array 4 years 7 months ago #70394

  • renu81072
  • renu81072's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
Have cut and pasted the code without any additions/ deletions from this forum to my source.. even then its the same...
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70396

  • renu81072
  • renu81072's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
Hi Guys!

Thanks a ton for your timely help.. Have resolved the issue and its working fine... :cheer:
Regards/ Renuka
The administrator has disabled public write access.

titles between subquestions of the same array 4 years 7 months ago #70407

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5974
  • Thank you received: 366
  • Karma: 260
renu81072 wrote:
Hi Guys!

Thanks a ton for your timely help.. Have resolved the issue and its working fine... :cheer:
Regards/ Renuka
You're welcome!

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.

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.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.262 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form