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

More
9 years 3 weeks ago #139843 by tpartner

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.

Based on your test survey, something like this should qork:

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.
More
9 years 3 weeks ago #139891 by lintu
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.

File Attachment:

File Name: limesurvey...4848.txt
File Size:16.21 KB


A big thanks to you both!
The topic has been locked.
More
9 years 3 weeks ago #139892 by lintu
Finally success!!! The following code works for me:
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.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose