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

TOPIC: Pre-set answer in radioboxes array

Pre-set answer in radioboxes array 5 years 9 months ago #57590

  • martijntk
  • martijntk's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
Regarding a social network analysis questionnaire, I would like to use an array-like approach

WEEKLY MONTHLY NEVER
name 1
name 2
name 3
...
name 300

The option "never" should be pre-set standard, because it is likely that respondents know a few of the others and will have to select only a few names. Is it possible to have the radioboxes under "NEVER" all checked standard?
The administrator has disabled public write access.

Pre-set answer in radioboxes array 5 years 9 months ago #57602

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6570
  • Thank you received: 1477
  • Karma: 579
If you're using a simple array with radio buttons, the following should work.

Set up your survey to use JavaScript and place the following script in the source of the array question. Replace "QQ" with the array question ID.

The script will loop through all rows and if no checked radios are found, the last one in that row will be checked.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		var qID = QQ;
 
		$('#question'+qID+' table.question tbody tr').each(function(i) { 
			if($('input.radio:checked', this).length < 1) {
				$('input.radio:last', this).attr('checked', true);
			}
		});
	});
 
</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.
Time to create page: 0.496 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form