Welcome, Guest
Username: Password: Remember me

TOPIC: Custom 'title' attribute for array checkbox

Custom 'title' attribute for array checkbox 2 years 4 months ago #80169

  • TCFAngus
  • TCFAngus's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
On an array 5 point choice question, I would like to change the mouse over label using the title="" html attribute.

Currently when you mouse over the check box buttons it displays the numbers( 1 - 5)

I'm familiar with the fullscreen and advanced options when editing the question.
In fact I am using
// A function to insert sub-title rows in an array

but I can't see where this is generating the line:
<input class="radio" type="radio" name="95149X5X85SQ001" id="answer95149X5X85SQ001-1" value="1" title="1" onclick="noop_checkconditions(this.value, this.name, this.type)" />

I want to change it to value="1" title="least"

Any ideas?

Thanks
Angus
The administrator has disabled public write access.

Re: Custom 'title' attribute for array checkbox 2 years 4 months ago #80190

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
There is no in-built feature to change this. I think the best solution would be to code some customized JavaScript to change the title value.

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: Custom 'title' attribute for array checkbox 2 years 4 months ago #80195

  • TCFAngus
  • TCFAngus's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Yes, I am playing with the javascript like:

document.getElementById(answer95149X5X85SQ001-1).title="Least useful"

but I am already using the code below and can't find the best place to insert it!

Thanks for the tip.
<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(85, 1, 'Local Information');
		insertSubTitle(85, 6, 'Regional Information');
		insertSubTitle(85, 9, 'National Information');
		insertSubTitle(85, 13, 'Information about specific thematic areas of work');
 
		// 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+'"><b>'+subtitle+'</b></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><br />
The administrator has disabled public write access.

Re: Custom 'title' attribute for array checkbox 2 years 4 months ago #80211

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
You can add the code either at the template.js file of the template you are using or add it in source code mode at the question.

See "How to use JavaScript at a Limesurvey template or survey" at www.limesurvey-consulting.com: www.limesurvey-consulting.com/how-to-use...-template-or-survey/

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'"
Last Edit: 2 years 4 months ago by Mazi.
The administrator has disabled public write access.

Re: Custom 'title' attribute for array checkbox 2 years 4 months ago #80297

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4195
  • Thank you received: 789
  • Karma: 359
You can insert your change any time after the document has loaded.

Something like this (using jQuery):
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$('#answer95149X5X85SQ001-1').attr('title', 'Least useful');
 
		// Call the function to insert sub-titles
 
		....
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.
Last Edit: 2 years 4 months ago by tpartner.
The administrator has disabled public write access.
The following user(s) said Thank You: TCFAngus
Moderators: ITEd
Time to create page: 0.214 seconds
Donation Image