Welcome to the LimeSurvey Community Forum

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

Expressions without <span> element? Is this a bug?

  • rcha88AA
  • rcha88AA's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 6 months ago - 5 years 6 months ago #183664 by rcha88AA
Hi, I am trying to do some conditional formatting in text boxes.

In my css code, via the 'Source' tab, I have css that contains:
Code:
border: {if(3==2, '2px', '20px')} solid black;
This produces the expected result (good) in the final html on the webpage, which is:
Code:
border: 20px solid black;

But when I try to use an answer as a variable, instead of fixed numbers:
Code:
border: {if(AB05==2, '2px', '20px')} solid black;
The final output is wrapped in a spam element, which is not good for me:
Code:
border: <span id='LEMtailor_Q_0_4'>20px</span> solid black;

The output only gets wrapped in a span if a question/answer is used? What is the reasoning for this?
Is there any way to make the output of the expression 'raw', and not wrapped in a span?
Is it a bug that the output in my first example is not wrapped in a span?


I believe I can achieve what I want via javascript but I think it is neat and simple to use how I trying to.

Thank you for any input! :)
Last edit: 5 years 6 months ago by rcha88AA.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
5 years 6 months ago #183682 by DenisChenu
Because your question AB05 is inside the same page.

You must use questions in previous page only.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • rcha88AA
  • rcha88AA's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 6 months ago - 5 years 6 months ago #183708 by rcha88AA
Thanks Denis.

I using values from previous pages. (Unless I misunderstand how LS functions)

My situation: My survey displays, I complete the answers, I click submit.
A new page is shown, with my End Message. (Found in 'Survey settings -> Text elements')
It is here in my end message that I want to use the values from questions/answers.
I can display the value as text OK, but it is always inside a <span> element and this is a problem if I want to use the number in javascript or css.

Version 3.14.9
Windows Server 2016
sqlsrv

Thank you


If anyone has my same problem and wants a quick cheap fix, it is quite simple to extract the value from the span element via javascript, which then I can use the value how I want. (Use to hide elements, change styles etc)
AB05 is the code id of the question I want to get the value of the answer from.
Code:
<script type="text/javascript" charset="utf-8">
   $(document).on('ready pjax:complete',function() {
 
      function extractContent(s) {
        var span = document.createElement('span');
        span.innerHTML = s;
        return span.innerText;
      };
 
     var my_value = extractContent("{AB05}");
     alert(my_value);
 
   });
</script>
Due to this being javascript, it is run after the page is complete and is client side.
If I could do what I wanted (use the value in css itself, without LS generating a span element), the value would be created server side, which is nice.
Last edit: 5 years 6 months ago by rcha88AA.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
5 years 6 months ago #183713 by DenisChenu
Can you sedn a sample LSS file (with only 2 or 3 questions)

if AB05 is in a page before {AB05} must never shown a span.

Maybe it's fixed in last version.

Denis
PS : about your scripot : remind you have jquery included : api.jquery.com/text/#text

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 6 months ago #183717 by tpartner

I using values from previous pages. (Unless I misunderstand how LS functions)

Try disabling AJAX in the survey theme options.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
5 years 6 months ago #183731 by DenisChenu
Checked with 3.17.2, using test{QCODE} for Class : OK, no issue class didn't have span.
I check at end message : no span too.

Ajax mode on or off :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The following user(s) said Thank You: rcha88AA
The topic has been locked.
More
5 years 5 months ago #184764 by surveyunihi
Replied by surveyunihi on topic Expressions without <span> element? Is this a bug?
Using 3.17.3, I had the same issue.

My sourcecode in a text display-question was:
Code:
<img src="https://localhost\jpgraph\generateimage.php?Param1={P1}&amp;amp;Param2={P2}" />

P1 and P2 are equation-questions.

I can confirm Denis' statement: the <span>-element only appears when using a (equation-)question from the same page (group).
My workaround was adding another group before, which contained only the equation-questions P1 and P2. Both questions where set to "always hide", so the whole group was invisible.

Best regards, Felix.
The topic has been locked.
More
5 years 5 months ago #184767 by jelo
Bugticket?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose