Welcome, Guest
Username: Password: Remember me

TOPIC: Prefilling text field from token?

Prefilling text field from token? 2 years 6 months ago #66419

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 170
  • Thank you received: 1
  • Karma: 3
Can I prefill a short text input-field with token values?

I can enter a token value in the answer prefix and answer suffix, but not in the text field itself.

I have been hoping for this feature for a long time ;) Is it possible now in 1.91?
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Prefilling text field from token? 2 years 6 months ago #66422

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
There is a workaround fr this at docs.limesurvey.org/Workarounds%3A+Manip..._personalized_limit_ (only the first code snippet applies).
Also search the forum, I think I have seen other examples there.

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'"
The administrator has disabled public write access.

Re: Prefilling text field from token? 2 years 6 months ago #66461

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 170
  • Thank you received: 1
  • Karma: 3
Hmmm, it says it is for a Multiple numerical input. I tried to enter this piece into the question of the short text field:
<script type="text/javascript" charset="utf-8">
function Custom_On_Load(){ 
   document.getElementById('answer1000X10X11').value='{TOKEN:ATTRIBUTE_1}'; 
   document.getElementById('answer1000X10X11').readOnly=1; 
} 
</script>
And changed it to:
<script type="text/javascript" charset="utf-8">
function Custom_On_Load(){ 
   document.getElementById('answer64197X8X71').value='{TOKEN:FIRSTNAME}'; 
   document.getElementById('answer64197X8X71').readOnly=1; 
} 
</script>
I actually searched in the forum for quite a while, but I couldn't find anything similar. Maybe I search for the wrong thing..
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
Last Edit: 2 years 6 months ago by waitz.
The administrator has disabled public write access.

Re: Prefilling text field from token? 2 years 6 months ago #66496

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 170
  • Thank you received: 1
  • Karma: 3
Ahh, look and thou shall find: www.limesurvey.org/forum/can-i-do-this-w...-table?lang=en#64477

The only thing is: when the 'multiple short text' are required fields, and the user misses one, then all fields are reset to original on submit. Is this possible to avoid?
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Prefilling text field from token? 2 years 6 months ago #66499

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
I think the best solution is to set the question to be not mandatory.

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'"
The administrator has disabled public write access.

Re: Prefilling text field from token? 2 years 6 months ago #66513

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 170
  • Thank you received: 1
  • Karma: 3
Mmm, I see it is as a workaround, although not so solid.

Would it be possible to use a script to define different subquestions to be required or not required?

Or to ensure a minimum number of possible answers, like we can in multiple choice with comments?
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Prefilling text field from token? 2 years 6 months ago #66516

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
Sorry, both isn't possible. The solution would be to write your own Javascript mandatory validation for this question.

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'"
The administrator has disabled public write access.

Re: Prefilling text field from token? 2 years 6 months ago #66518

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 170
  • Thank you received: 1
  • Karma: 3
I was afraid so ;)

I found one for array rows. Are they very different from sub questions?
docs.limesurvey.org/tiki-index.php?page=...f_an_array_mandatory
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Prefilling text field from token? 2 years 6 months ago #66519

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
You'd have to compare the IDs of the fields at the demo survey (www.partnersinc.biz/surveys//index.php?s...42&newtest=Y&lang=en) with your fields. I recommend using Firefox add-on Firebug which gives you the HTML details to a field by simply clicking on it. That makes it very comfortable to check the source code.

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'"
The administrator has disabled public write access.

Re: Prefilling text field from token? 2 years 6 months ago #66526

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 170
  • Thank you received: 1
  • Karma: 3
Interesting. I can probably use it by putting the sub-questions in x-scale and just one in the y-scale.

I looked with Firebug, and I could recognize some code, but it is more difficult to see where the script starts and where it ends... Would it be possible to see the actual test survey?
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
Last Edit: 2 years 6 months ago by waitz.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.221 seconds
Donation Image