Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

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

Can I use token attributes as default answers to questions? 3 Jahre 1 Monat 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? 3 Jahre 1 Monat her #62094

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4071
  • Dank erhalten: 748
  • Karma: 341
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 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.

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

  • TMSWhite
  • TMSWhites Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 759
  • Dank erhalten: 82
  • Karma: 36
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? 1 Jahr 8 Monate her #87686

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5301
  • Dank erhalten: 291
  • Karma: 247
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? 1 Jahr 6 Monate her #90999

  • Serafim
  • Serafims Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 114
  • Dank erhalten: 2
  • Karma: 2
Hi there, how do I do that?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Can I use token attributes as default answers to questions? 1 Jahr 3 Monate her #94529

  • ricardo
  • ricardos Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 110
  • Dank erhalten: 1
  • 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? 1 Jahr 3 Monate her #94534

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4071
  • Dank erhalten: 748
  • Karma: 341
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 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: ricardo
Moderatoren: ITEd
Ladezeit der Seite: 0.164 Sekunden
Donation Image