Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA: Additional Checkbox below textfield

Re: Additional Checkbox below textfield 1 Jahr 4 Monate her #96569

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4281
  • Dank erhalten: 807
  • Karma: 370
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:

Dateianhang:

Dateiname: limesurvey_survey_4768832.lss
Dateigröße: 15 KB
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.
Letzte Änderung: 1 Jahr 4 Monate her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: misterdot

Re: Additional Checkbox below textfield 1 Jahr 4 Monate her #96575

  • misterdot
  • misterdots Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 35
  • Dank erhalten: 1
  • Karma: 0
Works beautifully - thanks so much!
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.138 Sekunden
Donation Image