Check out the LimeSurvey source code on GitHub!

prefill sub questions from token table

More
5 years 6 months ago #64452 by janwillem64
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

Please Log in to join the conversation.

More
5 years 6 months ago #64454 by atiut
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".

Please Log in to join the conversation.

More
5 years 6 months ago #64466 by DenisChenu
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.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
5 years 6 months ago #64471 by janwillem64
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.

Please Log in to join the conversation.

More
5 years 6 months ago #64472 by DenisChenu

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:

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
Attachments:

Please Log in to join the conversation.

More
5 years 6 months ago #64473 by janwillem64
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>

Please Log in to join the conversation.

More
5 years 6 months ago - 5 years 6 months ago #64474 by DenisChenu

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_

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
Last Edit: 5 years 6 months ago by DenisChenu.

Please Log in to join the conversation.

More
5 years 6 months ago #64475 by janwillem64
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:

Please Log in to join the conversation.

More
5 years 6 months ago #64476 by janwillem64
Sorry. It is NOT anonymous. Participants are invited and have a token.

Please Log in to join the conversation.

More
5 years 6 months ago #64477 by DenisChenu
Hello,

Some script then, modify the survey.

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

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
Attachments:

Please Log in to join the conversation.

More
5 years 6 months ago #64480 by janwillem64
Perfect!! That's it.
Where do I put the javascript,in the question or the sub question?
And which code?

Please Log in to join the conversation.

More
5 years 6 months ago #64481 by DenisChenu
Where you want,

You can import the survey file in your installation, and look at the question source.

And :
docs.limesurvey.org/Workarounds%3A+Manip..._etc._in_LimeSurvey_

:)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
The following user(s) said Thank You: janwillem64

Please Log in to join the conversation.

More
5 years 4 months ago #66500 by Mazi
Shnoulle, can you add your solution to the workarounds? It is requested a lot in the forum to prefill questions with token values so documenting this would help a lot.

Thanks!


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 4 months ago - 5 years 4 months ago #66535 by DenisChenu

Mazi wrote: Shnoulle, can you add your solution to the workarounds? It is requested a lot in the forum to prefill questions with token values so documenting this would help a lot.

Thanks!

It's basically the same workaround here:
docs.limesurvey.org/Workarounds%3A+Manip...nswer_default_value_
And it need some optimisation:
test if input is empty,
do like Tony, a var QQ ...

But i put it if you want :).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
Last Edit: 5 years 4 months ago by DenisChenu.

Please Log in to join the conversation.

More
5 years 4 months ago #66552 by Mazi
Great, thanks!


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form