Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Limesurvey Prefilling answers

Limesurvey Prefilling answers 2 Jahre 2 Wochen her #78040

  • HMN
  • HMNs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 6
  • Karma: 0
Hello,

I need help, i have an array question like this:
YES NO NA
option 1
option 2
option 3
option 4

What i want is to prefill some answer, for example:

option 1 automatically have NA answer choosen, is it possible? How?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Limesurvey Prefilling answers 2 Jahre 2 Wochen her #78067

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5279
  • Dank erhalten: 289
  • Karma: 246
It depends on the Limesurvey version you are using. At Limesurvey 1.92 some more questions support default answers.

The alternative solution is to use Javascript to pre-check answers. There should be several examples at the forums.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Limesurvey Prefilling answers 2 Jahre 2 Wochen her #78088

  • HMN
  • HMNs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 6
  • Karma: 0
im using version 1.91+.
the problem is that i don't understand how to use javascript to prefill the answers.
i try this but doesnt do nothing:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#answer19716X147X177811').attr('checked', true);
});
survey ID: 19716
group ID: 147
question ID: 1778
i want that subquestion 1 have the answer 1 checked.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Limesurvey Prefilling answers 2 Jahre 2 Wochen her #78099

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3813
  • Dank erhalten: 683
  • Karma: 328
1) Set up your survey to use JavaScript.

2) Add the following script to the source of the array. Replace "QQ" with the array question ID (1778 in the example above).

The script looks for checked radios in the first row of the array and, if none found, checks the last one.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var qID = QQ;
 
		if($('#question'+qID+' table.question tbody:first input.radio:checked').length == 0) {
			$('#question'+qID+' table.question tbody:first input.radio:last').attr('checked', true); 
		}				
	});
 
</script>
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: HMN

Re: Limesurvey Prefilling answers 2 Jahre 2 Wochen her #78102

  • HMN
  • HMNs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 6
  • Karma: 0
thanks it works,

and if i want do checked the second and third rows of the array?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Limesurvey Prefilling answers 2 Jahre 2 Wochen her #78104

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3813
  • Dank erhalten: 683
  • Karma: 328
This will check the last option in the first three rows:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var qID = QQ;
 
		$('#question'+qID+' table.question tbody').each(function(i){
			if(i < 3) {
				if($('input.radio:checked', this).length == 0) {
					$('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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Letzte Änderung: 2 Jahre 2 Wochen her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: HMN

Limesurvey Prefilling answers 10 Monate 3 Wochen her #96514

  • boyan
  • boyans Avatar
  • OFFLINE
  • Senior Lime
  • Beiträge: 44
  • Dank erhalten: 8
  • Karma: 1
An easier solution is to use the survey URL. First, find the sid, qid and gid of the question as well as the answer option you are trying to prefill. For example,

sid=94757
gid=28
qid=660
answer option=A2

use the following URL

survey.xxx.org/index.php?sid=94757&94757X28X660=A2

BTW, sid is survey id, gid is groupid, qid is question id.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.146 Sekunden
Donation Image