Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Condition in end message

Condition in end message 2 years 7 months ago #76818

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
I need to include an extra message in the end message, which is only to be shown IF attribute_xx AND attribute_yy equals 1.

Can I do this with js?
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Condition in end message 2 years 7 months ago #76822

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
In version 1.92, you can do that by embedding expressions like this in the end message (e.g. you don't need JavaScript):
{if(attribute_xx==1 && attribute_yy==1,'message to show if true','message to show if false')}
The administrator has disabled public write access.

Re: Condition in end message 2 years 7 months ago #76842

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
TMSWhite wrote:
In version 1.92, you can do that by embedding expressions like this in the end message (e.g. you don't need JavaScript):
Just a question Tom : did it work with anonymous survey ?
The administrator has disabled public write access.

Re: Condition in end message 2 years 7 months ago #76847

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
I am not sure if I can go to 1.92 at the moment. I have a few import, export and js functions, so I have to test a lot first.

But is it possible with 1.91 and js? No surveys are anonymous
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Condition in end message 2 years 7 months ago #76848

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
waitz wrote:
But is it possible with 1.91 and js? No surveys are anonymous
If survey is anonymous you can't use TOKEN in your survey ...

( else survey aren't anonymous)

Denis
The administrator has disabled public write access.

Re: Condition in end message 2 years 7 months ago #76851

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
No no no, I wrote it wrong. It is a closed survey. All participants have a token.
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
Last Edit: 2 years 7 months ago by waitz.
The administrator has disabled public write access.

Re: Condition in end message 2 years 7 months ago #76862

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
waitz wrote:
No no no, I wrote it wrong. It is a closed survey. All participants have a token.
Yep, i understand.

But even with token table, you can set the survey to anonymous. If this is set, then you can't use token table in the survey.

If it's set to no-anonymous, try:
<script type='text/javascript'>
if ("{TOKEN:ATTRIBUTE_XX}"= "1" && "{TOKEN:ATTRIBUTE_YY}"= "1"){
document.write("message to show if true");
}else{
document.write("message to show if false");
}
</script>

Maybe you have to let the user to print answer to use it at end page. And if it not work : try if ("{ATTRIBUTE_XX}"= "1" && "{ATTRIBUTE_YY}"= "1") too.

Denis
Last Edit: 2 years 7 months ago by DenisChenu. Reason: TOKEN: or NOT ?
The administrator has disabled public write access.

Re: Condition in end message 2 years 7 months ago #76865

  • holch
  • holch's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 2852
  • Thank you received: 360
  • Karma: 125
If those attributes are already available in the token table, you could just create an extra attribute that indicates those that have both attributes before uploading the token file. Less JS.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.
The following user(s) said Thank You: DenisChenu

Re: Condition in end message 2 years 7 months ago #76873

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
DenisChenu wrote:
If it's set to no-anonymous, try:
<script type='text/javascript'>
if ("{TOKEN:ATTRIBUTE_XX}"= "1" && "{TOKEN:ATTRIBUTE_YY}"= "1"){
document.write("message to show if true");
}else{
document.write("message to show if false");
}
</script>

Maybe you have to let the user to print answer to use it at end page. And if it not work : try if ("{ATTRIBUTE_XX}"= "1" && "{ATTRIBUTE_YY}"= "1") too.

Denis
That's strange. On my local wamp server, none of them work.... {TOKEN:ATTRIBUTE_XX} or {ATTRIBUTE_XX}
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Condition in end message 2 years 7 months ago #76876

  • holch
  • holch's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 2852
  • Thank you received: 360
  • Karma: 125
Wouldn't it be easier to put a page with a boilerplate question for each text? OK, then you would have another page before you finish, but you could work with conditions.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.270 seconds
Donation Image