Custom 'title' attribute for array checkbox

More
5 years 4 months ago #80169 by TCFAngus
TCFAngus created the topic: Custom 'title' attribute for array checkbox
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

Please Log in to join the conversation.

More
5 years 4 months ago #80190 by Mazi
Mazi replied the topic: Custom 'title' attribute for array checkbox
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)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 4 months ago #80195 by TCFAngus
TCFAngus replied the topic: Custom 'title' attribute for array checkbox
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 />

Please Log in to join the conversation.

More
5 years 4 months ago - 5 years 4 months ago #80211 by Mazi
Mazi replied the topic: Custom 'title' attribute for array checkbox
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)survey-consulting.com'"
Last Edit: 5 years 4 months ago by Mazi.

Please Log in to join the conversation.

More
5 years 4 months ago - 5 years 4 months ago #80297 by tpartner
tpartner replied the topic: Custom 'title' attribute for array checkbox
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.
Last Edit: 5 years 4 months ago by tpartner.
The following user(s) said Thank You: TCFAngus

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now