Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

set a default value from token table when hiding the question

  • elementb
  • elementb's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 1 month ago #105275 by elementb
Hey there,

I have a "short free text" question to ask for the email adress.

I want to hide this question for people who have an email address in the token table -> WORKS

All others must enter their email address.


In the Results table I want to see all email addresses of people who have it in their token record as well.

I tried to set {TOKEN:EMAIL} in the default value field.

But it does not work ... is this because its a hidden question for them?


Any ideas?

Thank you so much.

Sabine
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 1 month ago - 10 years 1 month ago #105277 by tpartner
Yes, if the question is hidden by relevance or conditions, it will not be loaded with a default answer.

A solution may be to hide it with JavaScript instead of relevance.

1) remove the relevance or conditions from the question.

2) Use this as the default answer:
Code:
{if(TOKEN:EMAIL, TOKEN:EMAIL, '')}

3) Add this script to the source of the question:
Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function(){
    var tokenEmail = '{TOKEN:EMAIL}';
    if(tokenEmail.length > 0) {
      $('#question{QID}').hide();
    }
  });
</script>


.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 1 month ago by tpartner.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose