Welcome to the LimeSurvey Community Forum

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

Expressions within HTML tags

  • jessfishenden
  • jessfishenden's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #133761 by jessfishenden
Expressions within HTML tags was created by jessfishenden
Hello,

Can't tell whether this is a bug, or whether I'm missing a crucial element or escape character.

I want to dynamically generate the contents of a 'src' or 'href' variable inside an html tag, for example:
Code:
<a href="http://website.com/day.php?year={date('Y',strtotime(oneoffdate))}&amp;month={date('m',strtotime(oneoffdate))}&amp;day={date('d',strtotime(oneoffdate))}&amp;area=3">LINK</a>

The Expression in curly brackets seems to deal fine with being within the double quotes, but breaks when I add the < and > - the expression output (the 'year' variable in this example) gets changed into something like
Code:
<span id="LEMtailor_Q_238_64">1970</span>
Note this has also changed my input date from the original year to the unix epoch origin.

I'm running LS Version 2.06+ Build 150731
I have a live version of a survey that demonstrates the problem here, and the exported survey is also attached.
www.woodhousecommunitycentre.com/surveys...php/399574?newtest=Y

Any insight would be very much appreciated - is this a bug, or am I just missing something?
Attachments:
The topic has been locked.
  • holch
  • holch's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #133767 by holch
Replied by holch on topic Expressions within HTML tags
First of all, you need to make sure that your survey can use HTML (switch off the XSS filter) because it seems like Limesurvey is substituting the HTML codes.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • holch
  • holch's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #133768 by holch
Replied by holch on topic Expressions within HTML tags
But there is more going on. The EM codes work fine when outside of HTML, but when placed within the link, they get substituted by spans.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #133781 by DenisChenu
Replied by DenisChenu on topic Expressions within HTML tags

holch wrote: But there is more going on. The EM codes work fine when outside of HTML, but when placed within the link, they get substituted by spans.

Only if oneoffdate is on same page , no ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • jessfishenden
  • jessfishenden's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #133804 by jessfishenden
Replied by jessfishenden on topic Expressions within HTML tags
You're right! It works if it's on the next page.
Works regardless of XSS setting.

Unfortunately it's not much use to me if people have to click back and forth between pages.

Most other use of expressions can work fully on the same page, as these date elements do outside of the tag.
I can't tell what makes the difference!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #133812 by DenisChenu
Replied by DenisChenu on topic Expressions within HTML tags
If it's on same page : we need a way to update when user update oneoffdate.

Then we must add something .....

You can not do different

For your purpose :
Code:
<a id="toto" name="toto">The link</a>
<span id="totolink" style="display:none">http://website.com/day.php?year={date('Y',strtotime(oneoffdate))}&amp;month={date('m',strtotime(oneoffdate))}&amp;day={date('d',strtotime(oneoffdate))}&amp;area=3</span>
<script>
$("#toto").on("click",function(){
window.location.href=$("#toto").text();
});
</script>

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • jessfishenden
  • jessfishenden's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #133818 by jessfishenden
Replied by jessfishenden on topic Expressions within HTML tags
I'm very unfamiliar with javascript, but it looks like that's the only way.

That code does make sense, though, thanks for the help.

I'm happy to implement a workaround to make this work, but it still feels like a bug to me, do you think it needs to be reported as one?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago - 7 years 11 months ago #133843 by DenisChenu
Replied by DenisChenu on topic Expressions within HTML tags
Hi,

You can report if you want (sometimes my english seem unclear ;) ). But it's not a bug.
- User can update his answer in same page
- Then we must update it in the page.

If we set {date('m',strtotime(oneoffdate))} to 2015 without a span : there are no difference with another 2015 in same page. Then we can not easily update it [* see example].

It's more a big dev/feature request, maybe 3.1/3.2 have a system to load the question content in ajax : but then i think it take a lot mlore time when the user click on another answer.

*
You use
Code:
{date('m',strtotime(oneoffdate))} or 2015
set to
Code:
2015 or 2015
No human can see the difference betwwen the 2 2015 => computer can not too.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 7 years 11 months ago by DenisChenu.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose