- Posts: 10611
- Thank you received: 3691
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Need some help with a code snippet please
- tpartner
- Away
- LimeSurvey Community Team
Less
More
7 years 7 months ago #139822
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 Need some help with a code snippet please
Denis' $('body .content') selector was just an example. The correct selector would depend on your template. Can you activate a test survey and give us a link and also attach a mockup of where you want the image?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- lintu
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 97
- Thank you received: 7
7 years 7 months ago - 7 years 7 months ago #139824
by lintu
Replied by lintu on topic Need some help with a code snippet please
tpartner,
Here's a link to my test assessment: Link
There are two questions on this assessment - on the first question, I am displaying two images on top of the answers by inserting code in the question.pstpl template. I want to hide these images for the 2nd question.
Thanks in advance for all your help!!
Here's a link to my test assessment: Link
There are two questions on this assessment - on the first question, I am displaying two images on top of the answers by inserting code in the question.pstpl template. I want to hide these images for the 2nd question.
Thanks in advance for all your help!!
Last edit: 7 years 7 months ago by lintu.
The topic has been locked.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12713
- Thank you received: 3926
7 years 7 months ago #139833
by Joffm
Hi, lintu,
of course not.
This EXCEL file is the survey structure, more or less the same as the *.lss.
What I suggested was, that you remove the picture code in columns 37 (dualscale_headerA) and 38 (dualscale_headerB) in the desired questions.
By filtering the file by question code this is done very quickly - without the JavaScript stuff.
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Need some help with a code snippet please
lintu wrote: P.S. Joffm - I exported the survey excel file as you suggested, but my custom code is not in there for me to remove as I inserted it in the template.
Hi, lintu,
of course not.
This EXCEL file is the survey structure, more or less the same as the *.lss.
What I suggested was, that you remove the picture code in columns 37 (dualscale_headerA) and 38 (dualscale_headerB) in the desired questions.
By filtering the file by question code this is done very quickly - without the JavaScript stuff.
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
7 years 7 months ago #139843
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 Need some help with a code snippet please
Based on your test survey, something like this should qork:I am displaying an image on top of the answer selections (see screenshot below) for every question. Since I have over 100+ questions, instead of adding this to each answer, I inserted my code in the question.pstpl template. Now, for select questions, I want to hide this based on the question # or question code.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var q = '{QUESTION_CODE}'; if (q == 'Q1') { // Hide the images table $('.no-more-tables-array-dual').prevAll('center:eq(0)').hide; } else { // Do nothing } }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- lintu
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 97
- Thank you received: 7
7 years 7 months ago #139891
by lintu
Replied by lintu on topic Need some help with a code snippet please
Hello tpartner,
Thanks for the helpful code snippet. Unfortunately it did not work for me. I tried by placing the code both in the question template and EM.
Joffm,
I had another look in the survey structure excel file that I downloaded (attached), but for my desired question (#2) there is no picture code in columns 37 (dualscale_headerA) and 38 (dualscale_headerB) for me to remove.
A big thanks to you both!
Thanks for the helpful code snippet. Unfortunately it did not work for me. I tried by placing the code both in the question template and EM.
Joffm,
I had another look in the survey structure excel file that I downloaded (attached), but for my desired question (#2) there is no picture code in columns 37 (dualscale_headerA) and 38 (dualscale_headerB) for me to remove.
A big thanks to you both!
Attachments:
The topic has been locked.
- lintu
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 97
- Thank you received: 7
7 years 7 months ago #139892
by lintu
Replied by lintu on topic Need some help with a code snippet please
Finally success!!! The following code works for me:
Thanks again for all your support - really appreciate it!
Code:
<CENTER> <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR> <TD ALIGN=CENTER><img id="customimage1" src="images/current_state.jpg"></TD> </TD> </TABLE></CENTER> <script> var q = '{QUESTION_CODE}'; if (q == 'q1') { //Hide the image for this question document.getElementById("customimage1").style.display = 'none'; } </script>
Thanks again for all your support - really appreciate it!
The topic has been locked.