Welcome to the LimeSurvey Community Forum

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

titles between subquestions of the same array

More
12 years 3 months ago #70373 by renu81072
Replied by renu81072 on topic titles between subquestions of the same array
Can you let me know what will the whole code be like. Since I would want one line without radio button.. next few lines will should have radio button.. again in between a sub-heading and so on. If you could share with me the full code for this, would appreciate.

Am using the latest limesurvey... Am using Array option
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 3 months ago - 12 years 3 months ago #70374 by tpartner
Replied by tpartner on topic titles between subquestions of the same array
Rather than hide radios of sub-questions, I would use JavaScript to insert new rows with the sub-titles.

The following example workaround will insert new rows at positions 1, 3 and 6 as in the image below.

1) Set up your survey to use JavaScript .

2) Add the following script to the source of the array. Replace "QQ" with the array question ID and adjust the row numbers and subtitles as necessary.
Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).ready(function() {
 
    // Call the function to insert sub-titles
    // Parameters (Question ID, Row number, Sub-title)
    insertSubTitle(QQ, 1, 'Group 1');
    insertSubTitle(QQ, 3, 'Group 2');
    insertSubTitle(QQ, 6, 'Group 3');
 
    // A function to insert sub-title rows in an array
    function insertSubTitle(qID, row, subtitle) {
 
      // Add some row-specific classes
      $('#question'+qID+' table.question tbody[id^="javatbd"]').each(function(i, el){
        $(el).addClass('ansRow-'+(i+1));
      });
 
      // Find number of columns
      var cols = $('#question'+qID+' table.question tbody[id^="javatbd"]:first tr:first > *').length;
 
      // Define the row to be inserted
      var insertedRow = '<tbody> \
                  <tr class="insertedRow"> \
                    <td colspan="'+cols+'">'+subtitle+'</td> \
                  </tr> \
                </tbody>';
 
      // And insert the row
      $(insertedRow).insertBefore('#question'+qID+' .ansRow-'+row+'');
 
      // Fix up the row background colours
      var rowIndex = 0;
      $('#question'+qID+' table.question tr').each(function(i, el){
        rowIndex ++;
        if($(el).hasClass('insertedRow')) {
          rowIndex = 0;
        }
 
        $(el).removeClass('array1, array2');
 
        if(rowIndex % 2 == 0) {
          $(el).addClass('array1');
        }
        else {
          $(el).addClass('array2');
        }
      });
    }
 
  });
 
</script>

3) Add the following rules to the end of your template.css file:
Code:
.insertedRow {
  background-color: #66CCCC;
  font-weight: bold;
}
 
.insertedRow td {
  text-align: left !important;
}


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 12 years 3 months ago by tpartner.
The topic has been locked.
More
12 years 3 months ago #70380 by renu81072
Replied by renu81072 on topic titles between subquestions of the same array
Hi: Have included the javascript while creating the array question. i.e., have inserted after the text what needs to get displayed in the source... Also the other code in the template.css file... but am attaching as to how it looks after have done all these changes...

Am using 1.91+ version

Regards
Renu
Attachments:
The topic has been locked.
More
12 years 3 months ago #70382 by renu81072
Replied by renu81072 on topic titles between subquestions of the same array
have replaced QQ with the QuestionID... even then its the same ... :( :(
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 3 months ago #70383 by DenisChenu
Replied by DenisChenu on topic titles between subquestions of the same array

tpartner wrote: 1) Set up your survey to use JavaScript .

Look at this part:

Go to Global settings --> Security and set "Filter HTML for XSS" to "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 topic has been locked.
More
12 years 3 months ago #70384 by renu81072
Replied by renu81072 on topic titles between subquestions of the same array
Hi.. Now the code does not get displayed.. Thanks.. But still as seen in your image of array1 question, the grouping is not happening.. :(

Have added this code in the template.css
.insertedRow { background-color: #66CCCC; font-weight: bold;} .insertedRow td { text-align: left !important;}

The other code in source... but still the grouping is not happening.. :(
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 3 months ago #70385 by tpartner
Replied by tpartner on topic titles between subquestions of the same array
Can you activate a sample survey for me to see?

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
12 years 3 months ago #70386 by renu81072
The topic has been locked.
More
12 years 3 months ago #70387 by renu81072
The topic has been locked.
More
12 years 3 months ago #70388 by renu81072
Replied by renu81072 on topic titles between subquestions of the same array
Am online as of now.. Can we chat ??
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 3 months ago #70389 by tpartner
Replied by tpartner on topic titles between subquestions of the same array
There are many line breaks missing in the script in your survey. Try copying and pasting it in again directly from the post above.

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
12 years 3 months ago #70394 by renu81072
Replied by renu81072 on topic titles between subquestions of the same array
Have cut and pasted the code without any additions/ deletions from this forum to my source.. even then its the same...
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose