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

THEMA: Can I use token attributes as default answers to questions?

Can I use token attributes as default answers to questions? 2 Jahre 1 Woche her #62050

  • MikeFloyd
  • MikeFloyds Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 5
  • Karma: 0
Can I use token attributes as default answers to questions?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Can I use token attributes as default answers to questions? 2 Jahre 1 Woche her #62094

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 2944
  • Dank erhalten: 448
  • Karma: 254
Yes.

1) Set up your survey to use JavaScript.

2) Add the following script to the source of the question. Replace "QQ" with the questionquestion ID.

If the text input is empty the script loads it with the token value.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		var qID = QQ;
 
		if($('#question'+qID+' input.text').val() == '') {
 
			$('#question'+qID+' input.text').val('{TOKEN:ATTRIBUTE_1}');
		}
 
	});
 
</script>
Cheers,
Tony

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Can I use token attributes as default answers to questions? 2 Jahre 1 Woche her #62126

  • TMSWhite
  • TMSWhites Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 751
  • Dank erhalten: 77
  • Karma: 33
tpartner-

This seems like another common request that the equation parser and Issue #5104 might be able to help with.

The way I've done this in the past was to create hidden Equation questions which could set the value of other variables (e.g. set default values for answers).

/tom
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Can I use token attributes as default answers to questions? 7 Monate 2 Wochen her #87686

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5118
  • Dank erhalten: 264
  • Karma: 241
At Limesurvey 2 (and already at 1.92 as well), you can set default answers using the Expression Manager.

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: Can I use token attributes as default answers to questions? 5 Monate 1 Woche her #90999

  • Serafim
  • Serafims Avatar
  • ONLINE
  • Expert Lime
  • Beiträge: 88
  • Karma: 1
Hi there, how do I do that?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Can I use token attributes as default answers to questions? 2 Monate 2 Wochen her #94529

  • ricardo
  • ricardos Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 85
  • Karma: 0
Hello,

I have a multiple short text question. I'd like to prepopulate some of the fields with data from the token list. I have tried this but have not been able to make it work.

This is the script I'm using

<script type="text/javascript" charset="utf-8">

$(document).ready(function(){

var qID = 8568SQ001;

if($('#question'+qID+' input.text').val() == '') {

$('#question'+qID+' input.text').val('{TOKEN:ATTRIBUTE_1}');
}

});

</script>

8568 is the question ID and SQ001 is the code for the first option in the multiple short text question. Is it possible to make this work on this type of question?

thanks
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Can I use token attributes as default answers to questions? 2 Monate 2 Wochen her #94534

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 2944
  • Dank erhalten: 448
  • Karma: 254
You shouldn't need that.

You should be able to set the default answer in the LS interface:

Capture2_2013-04-03.JPG
Cheers,
Tony

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: ricardo
  • Seite:
  • 1
Moderatoren: DenisChenu, ITEd
Ladezeit der Seite: 0.238 Sekunden
Donation Image