Welcome, Guest
Username: Password: Remember me

TOPIC: Conditions with token attributes

Conditions with token attributes 3 years 7 months ago #58398

  • avadillo
  • avadillo's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Hello,

I started using LimeSurvey this week and I have no experience with HTML and Javascript, so I guess my question is going to be a stupid one... Anyway, here I go:

What I want to do is, depending on the value of a Token attribute (in this case Y/N), I want to show different lines in a message/question. I've tried this:

<SCRIPT LANGUAGE=JavaScript>

var att = {TOKEN:ATTRIBUTE_1};

if (att = Y)
{
document.write("Attribute 1");
}
</script>


And it never shows anything, even though attribute_1 is equal to Y.

Sorry for my english.
Last Edit: 3 years 7 months ago by avadillo.
The administrator has disabled public write access.

Re: Conditions with token attributes 3 years 7 months ago #58402

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
There are some restriction in Token using in text question.

See docs.limesurvey.org/Adding+a+question#In...on_from_tokens_table

:)
The administrator has disabled public write access.

Re: Conditions with token attributes 3 years 7 months ago #58408

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4277
  • Thank you received: 807
  • Karma: 370
And it never shows anything, even though attribute_1 is equal to Y.
You forgot a couple of quotes and an equals sign:
<SCRIPT LANGUAGE=JavaScript>
 
	var att = '{TOKEN:ATTRIBUTE_1}';
 
	if (att == Y) {
		document.write("Attribute 1");
	}
</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.
The administrator has disabled public write access.

Re: Conditions with token attributes 3 years 7 months ago #58410

  • avadillo
  • avadillo's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Thank you for your answers, it finally worked with this code
<script type="text/javascript" language="Javascript">;
        if ('{TOKEN:ATTRIBUTE_1}'=='Y') {
       document.write ('Attribute 1')
    } 
</script>
The administrator has disabled public write access.

Re: Conditions with token attributes 3 years 7 months ago #58459

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5331
  • Thank you received: 296
  • Karma: 249
You're welcome!

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.

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.
Moderators: ITEd
Time to create page: 0.183 seconds
Donation Image