Default selected "Yes" for a particular question

Mehr
7 Jahre 4 Monate her #83487 von amritdeep
In my survey there is question

Que: Is it ok?
yes/no


I want that "Yes" selected by default.
for this i have used following code what didn't work


<script type="text/javascript" charset="utf-8">
document.getElementById('answer82352X12X333Y').checked = 'checked';
</script>

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

LimeSurvey Partners
Mehr
7 Jahre 4 Monate her - 7 Jahre 4 Monate her #83496 von Ben_V
Try this one ;)
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
	document.getElementById('answer82352X12X333Y').checked = 'checked';
	});
</script>
Ben/

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Letzte Änderung: 7 Jahre 4 Monate her von Ben_V.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
7 Jahre 4 Monate her #83509 von amritdeep
Its working. Thanks a lot Sir ! :) :)

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
7 Jahre 4 Monate her #83531 von tpartner
You may want to put in a conditional so the default only gets checked if nothing has already been checked:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		if($('#question333 input.radio:checked').length == 0) {
			document.getElementById('answer82352X12X333Y').checked = 'checked';
		}
 
	});
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
7 Jahre 4 Monate her - 7 Jahre 4 Monate her #83537 von amritdeep
This code is working for default radio buttons.

But i am using images for radio buttons.
As you described in your workaround "Use images for radio buttons and checkboxes".


In the case of "Images for radio buttons" this code is not working.




Anhänge:
Letzte Änderung: 7 Jahre 4 Monate her von amritdeep.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
7 Jahre 2 Monate her #86164 von startx25
Amritdeep, do you have find a solution, i have the same problem.

Thank for your help

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
7 Jahre 2 Monate her #86239 von tpartner

In the case of "Images for radio buttons" this code is not working.

It should work with the imageTick plugin if you place the code that selects the radio button BEFORE the code that applies imageTick.
$(document).ready(function(){ 
 
	if($('#question333 input.radio:checked').length == 0) {
		document.getElementById('answer82352X12X333Y').checked = 'checked';
	}
 
	// Apply images to radios 
	$('input[type="radio"]').imageTick({ 
		// Image to use as a selected state of the radio
		tick_image_path: "upload/templates/yourTemplateName/radio.gif", 
		// Image to use as a non-selected state 
		no_tick_image_path: "upload/templates/yourTemplateName/no_radio.gif", 
		// Class to apply to all radio images that are dynamically created 
		image_tick_class: "radios"
	}); 
 
	// Apply images to checkboxes 
	$('input[type="checkbox"]').imageTick({ 
		// Image to use as a selected state of the checkbox  
		tick_image_path: "upload/templates/yourTemplateName/check.gif",  
		// Image to use as a non-selected state 
		no_tick_image_path: "upload/templates/yourTemplateName/no_check.gif", 
		// Class to apply to all checkbox images that are dynamically created 
		image_tick_class: "checkboxes" 
	}); 
});

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
7 Jahre 2 Monate her #86274 von startx25
Thank you very much tpartner

That's work fine : BEFORE the code that applies imageTick.

Regards,
Startx25

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha