Welcome, Guest
Username: Password: Remember me

TOPIC: set a default value from token table when hiding the question

set a default value from token table when hiding the question 2 months 1 day ago #105275

  • elementb
  • elementb's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
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 administrator has disabled public write access.

set a default value from token table when hiding the question 2 months 1 day ago #105277

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
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:
{if(TOKEN:EMAIL, TOKEN:EMAIL, '')}

3) Add this script to the source of the question:
<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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 2 months 1 day ago by tpartner.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.163 seconds
Donation Image