Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Additional Checkbox below textfield

Additional Checkbox below textfield 5 years 5 months ago #61844

Hello,

I am trying to setup a survey where some questions consist of three radio buttons, an additional textfield for comments and a checkbox below this textfield. With the additional checkbox the participants can mark that the comment in the textbox is of high importance for them.

To demonstrate what I mean, a short (photoshoped) example.



So my question is: is there a possibility to add a checkbox like this? Beyond that, is there a way to change the "Please enter your comment here" to something else (varying from question to question).

Appreciate any help

Greetings
Last Edit: 5 years 5 months ago by Dolgsthrasir. Reason: typo
The administrator has disabled public write access.

Additional Checkbox below textfield 5 years 5 months ago #61866

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
To get the checkbox you will need to use another question. Add a multiple choice question with no question text (or hide the question text with CSS) and only one sub-question.

To dynamically modify the label text:

1) Set up your survey to use JavaScript.

2) Add the following script to the source of the question. Replace "QQ" with the question ID.
<script type="text/javascript" charset="utf-8">
 
	$('#questionQQ p.comment label').text('Some new label text...');
 
</script>
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.

Additional Checkbox below textfield 5 years 5 months ago #61869

It works, thank you very much!
The administrator has disabled public write access.

Aw: Additional Checkbox below textfield 4 years 5 months ago #82660

  • FLF
  • FLF's Avatar
  • Offline
  • Junior Lime
  • Posts: 24
  • Karma: 0
Hello,
I have the same problem like Dolgsthrasir. I want to change the text "Please enter your comment here"
So I used the javascript like described, but it doesn't work.
Is it possible that the the limesurvey version Version changed and that's the reason.

I use version 1.92+
The administrator has disabled public write access.

Additional Checkbox below textfield 4 years 5 months ago #82665

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
No, that selector should still work.

Can you activate a sample survey with your code in it?
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.

Additional Checkbox below textfield 4 years 5 months ago #82723

  • FLF
  • FLF's Avatar
  • Offline
  • Junior Lime
  • Posts: 24
  • Karma: 0
Thank you for your answer.
Now it works. For some reason in the HTML source code the javascript code was above the code for the question.
So I included the javasript code into the question-group endgroup.pstpl and now it works. I know that the code is now in every question-group, but I think that there should be no problem.
The administrator has disabled public write access.

Additional Checkbox below textfield 4 years 5 months ago #82729

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
Oh, wait, I see the problem. The script is being fired before the page is loaded.

This should work in the question source:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		$('#questionQQ p.comment label').text('Some new label text...');
	});
 
</script>
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.

Additional Checkbox below textfield 4 years 5 months ago #82739

  • FLF
  • FLF's Avatar
  • Offline
  • Junior Lime
  • Posts: 24
  • Karma: 0
:) thank you!!
The administrator has disabled public write access.

Additional Checkbox below textfield 4 years 5 months ago #82853

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6027
  • Thank you received: 373
  • Karma: 260
FLF wrote:
:) thank you!!
You're welcome :-)

If our hints have been helpful and you enjoy limesurvey please consider a donation to give Limesurvey a future .
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)survey-consulting.com'"
The administrator has disabled public write access.

Additional Checkbox below textfield 3 years 6 months ago #96546

  • misterdot
  • misterdot's Avatar
  • Offline
  • Junior Lime
  • Posts: 39
  • Thank you received: 1
  • Karma: 0
I'm having trouble getting this to work. I'm using Version 2.00+ Build 130305 and javascript is enabled (using it elsewhere). I've attached a screen shot of what I'd like it to be and a sample (not working) survey. Can't figure out what I'm doing wrong.
Thanks!
Matt
Attachments:
The administrator has disabled public write access.

Additional Checkbox below textfield 3 years 6 months ago #96569

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
Here is an updated script that hides the check-box question and moves the check-box and label into the numeric question.

This script also makes the numeric input and check-box exclusive.

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
 
		// Identify the questions
		var q1ID = '{QID}';
		var q1 = $('#question'+q1ID+'');
		var q2 = $(q1).nextAll('.multiple-opt:eq(0)'); 
		var q2ID = $(q2).attr('id').split('question')[1];
 
		// Hide Q2
		$(q2).css({
			'position': 'absolute',
			'left': '-9999em'
		});
 
		// Move the checkbox and label to Q1
		$('.answer-item', q1).after($('.checkbox-list', q2));
 
		// Some cleanup styles
		$('.checkbox-list', q1).css({
			'margin-left': $('.answer-item', q1).css('margin-left'),
			'list-style': 'none'
		})
 
		// Listener on the numeric input
		$('input[type="text"]', q1).keyup(function(){
			if($(this).val() != '') {
				$('input.checkbox', q1).attr('checked', false);
			}
		});
 
		// Listener on the checkbox
		$('input.checkbox', q1).change(function(){
			if($(this).attr('checked') == true) {
				$('input[type="text"]', q1).val('');
			}
		});
	});
</script>


Here is the survey back with the updated script in the source of the numeric question:

File Attachment:

File Name: limesurvey...8832.lss
File Size:15 KB
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 3 years 6 months ago by tpartner.
The administrator has disabled public write access.
The following user(s) said Thank You: misterdot

Additional Checkbox below textfield 3 years 6 months ago #96575

  • misterdot
  • misterdot's Avatar
  • Offline
  • Junior Lime
  • Posts: 39
  • Thank you received: 1
  • Karma: 0
Works beautifully - thanks so much!
The administrator has disabled public write access.
Time to create page: 0.521 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form