Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: prefill sub questions from token table

prefill sub questions from token table 2 years 8 months ago #64452

Hello,
I've been looking for hours in the forum but can't find the answer for:
I have a token table which contains fields like name and address.
I would like to use thes values als prefill.
It should look like this:
<label>Name: <value prefilled and can be changed is field LASTNAME from token table>.
Javascirpt is working. I'v tried to put this in the subquestion:
Achternaam:
<script type="text/javascript" charset="utf-8">$(document).ready(function() {document.getElementById("answer41645X5X66ANAAM").value = '{TOKEN:LASTNAME}'});</script>
But is doesn't work.
Any ideas?
Thanks,
Jan Willem
The administrator has disabled public write access.

Re: prefill sub questions from token table 2 years 8 months ago #64454

  • atiut
  • atiut's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 76
  • Thank you received: 2
  • Karma: 1
Have you tried puting the token data in the invitation link and using the invitation link to prefill the questions? (docs.limesurvey.org/Workarounds%3A+Surve...using_the_survey_URL) I am pretty sure i have seen a mode detailed tutorial somewhere.

And then, there is always the dirty way: put the data in the question text and leave the answer empty: "You said your name was {TOKEN:LASTNAME}. Please correct it below if necessay".
The administrator has disabled public write access.

Re: prefill sub questions from token table 2 years 8 months ago #64466

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5866
  • Thank you received: 718
  • Karma: 222
Hello,

You can use {TOKEN:*} only if your survey are set to be not anonymous.

And then you can use directly {TOKEN:LASTNAME} in you subquestion i think.
The administrator has disabled public write access.

Re: prefill sub questions from token table 2 years 8 months ago #64471

Putting the data in the url is not an elegant solution...

I already have the dirty ready but it would be nice if I can use the prefill.
The administrator has disabled public write access.

Re: prefill sub questions from token table 2 years 8 months ago #64472

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5866
  • Thank you received: 718
  • Karma: 222
janwillem64 wrote:
Putting the data in the url is not an elegant solution...

I already have the dirty ready but it would be nice if I can use the prefill.
Did you survey is anonymous or not ?

I made an example, maybe you can see if it's what your want or not:
Test this link with token TEST or TEST2

demonstration.sondages.pro/index.php?sid...46&newtest=Y&lang=en

The survey:
Attachments:
The administrator has disabled public write access.

Re: prefill sub questions from token table 2 years 8 months ago #64473

It is anonymous.
When looking in the source code of the question page I see the values but they are linked to the label...?
<li>
<label for="answer41645X5X66ANAAM">Achternaam: <script type="text/javascript" charset="utf-8">$(document).ready(function() {document.getElementById("answer41645X5X66ANAAM").value = 'lange'});</script></label>
<span>

<input class="text " size="50" name="41645X5X66ANAAM" id="answer41645X5X66ANAAM" value="" onkeyup="noop_checkconditions(this.value, this.name, this.type);" maxlength="100" type="text">

</span>
</li>
The administrator has disabled public write access.

Re: prefill sub questions from token table 2 years 8 months ago #64474

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5866
  • Thank you received: 718
  • Karma: 222
janwillem64 wrote:
It is anonymous.
If your survey is anonymous, you CAN'T use token table in your question or label or ....

And after you can use some javascript.
docs.limesurvey.org/Workarounds%3A+Manip...nswer_default_value_
Last Edit: 2 years 8 months ago by DenisChenu.
The administrator has disabled public write access.

Re: prefill sub questions from token table 2 years 8 months ago #64475

Looked at your test but not exactly what I mean. I made a screenshot of the question. It's dutch. The question is:
We have the following name and address information of you. Please correct them below if not correct. Than it would be nice if the fields are prefilled.
Attachments:
The administrator has disabled public write access.

Re: prefill sub questions from token table 2 years 8 months ago #64476

Sorry. It is NOT anonymous. Participants are invited and have a token.
The administrator has disabled public write access.

Re: prefill sub questions from token table 2 years 8 months ago #64477

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5866
  • Thank you received: 718
  • Karma: 222
Hello,

Some script then, modify the survey.

demonstration.sondages.pro/index.php?sid...46&newtest=Y&lang=en
Attachments:
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.119 seconds
Donation Image