- Posts: 15
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
4 years 11 months ago - 4 years 11 months ago #183664
by rcha88AA
Expressions without <span> element? Is this a bug? was created 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:
This produces the expected result (good) in the final html on the webpage, which is:
But when I try to use an answer as a variable, instead of fixed numbers:
The final output is wrapped in a spam element, which is not good for me:
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!
In my css code, via the 'Source' tab, I have css that contains:
Code:
border: {if(3==2, '2px', '20px')} solid black;
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;
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: 4 years 11 months ago by rcha88AA.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
4 years 11 months ago #183682
by DenisChenu
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.
Replied by DenisChenu on topic Expressions without <span> element? Is this a bug?
Because your question AB05 is inside the same page.
You must use questions in previous page only.
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 service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- rcha88AA
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 0
4 years 11 months ago - 4 years 11 months ago #183708
by rcha88AA
Replied by rcha88AA on topic Expressions without <span> element? Is this a bug?
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.
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.
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>
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: 4 years 11 months ago by rcha88AA.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
4 years 11 months ago #183713
by DenisChenu
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.
Replied by DenisChenu on topic Expressions without <span> element? Is this a bug?
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
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 service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 11 months ago #183717
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Expressions without <span> element? Is this a bug?
Try disabling AJAX in the survey theme options.I using values from previous pages. (Unless I misunderstand how LS functions)
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
4 years 11 months ago #183731
by DenisChenu
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.
Replied by DenisChenu on topic Expressions without <span> element? Is this a bug?
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
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 service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: rcha88AA
The topic has been locked.
- surveyunihi
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
4 years 10 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:
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.
My sourcecode in a text display-question was:
Code:
<img src="http://localhost\jpgraph\generateimage.php?Param1={P1}&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.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
4 years 10 months ago #184767
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Expressions without <span> element? Is this a bug?
Bugticket?
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.