- Posts: 14249
- Thank you received: 2576
Ask the community, share ideas, and connect with other LimeSurvey users!
You're welcomeiosononando wrote: This is fantastic!!! Thanks a lot!!!! I will put my hands on it right away!
function sideBySide(rows, columns) {
function sideBySide(rows, columns, startQuestion) {
if(rowNum <= rows) {
if(rowNum <= rows && i >= startQuestion-1) {
sideBySide(5, 5);
sideBySide(5, 5, 3);
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Call the "sideBySide" function with number of rows, columns and the start question number sideBySide(5, 5, 3); }); function sideBySide(rows, columns, startQuestion) { /*********** Display multiple questions side by side ***********/ if ($('div.qRow1').length == 0) { var rowNum = 0; var colNum = 1; var rowList = new Array(); //////// Add question classes for later use //////// // Loop through all questions and add row and column specific classes $('div[id^="question"]').each(function(i) { /* This IF condition only needed if there are questions preceding or following the "inline" questions*/ if(rowNum <= rows && i >= startQuestion-1) { $(this).addClass('qRow'+rowNum+'').addClass('qCol'+colNum+'').addClass('inlineQuestion'); if(rowNum == 0 && colNum > 1) { $(this).addClass('columnLabel'); } if(rowNum > 0 && colNum == 1) { $(this).addClass('rowLabel'); } else if(rowNum > 0 && colNum > 1) { $(this).addClass('questionCell'); } if(colNum == columns) { rowList.push('qRow'+rowNum+''); rowNum++; colNum = 1; } else { colNum++; } } else { $(this).addClass('normalQuestion'); } }); //////// Survey layout manipulation //////// // Fix the width of the survey $('table.outerframe').css({ 'width': '900px' }); // Wrap each "row" in a wrapper div $(rowList).each(function(i) { $('.'+this+'').wrapAll('<div id="inlineWrapper'+i+'" class="inlineRow" />'); }); // Style the wrapper divs $('.inlineRow').css({ 'width': '850px', 'margin': '0 auto 0 auto', 'clear': 'both' }); $( '.inlineRow:first' ).css({ 'margin-top': '10px' }); // Get all the questions to sit politely side by side $( '.inlineQuestion' ).css({ 'float': 'left', 'height':'41px', 'overflow':'hidden', 'margin-bottom': '-5px' }); $( '.inlineQuestion .questionhelp' ).hide(); $( '.inlineQuestion .survey-question-help' ).parent().hide(); // A little space under the last row $( '.inlineRow:last .inlineQuestion' ).css({ 'margin-bottom': '10px' }); /* Any questions not displayed inline (this is only needed if there are questions following the "inline" questions)*/ $( '.normalQuestion' ).css({ 'clear': 'both' }); //////// Column manipulation //////// // Set the column widths - can be set individually if necessary // Must add up to less than 100% $( '.qCol1' ).css({ 'width': '12%' }); $( '.qCol2, .qCol3, .qCol4, .qCol5' ).css({ 'width': '22%' }); //////// Question manipulation //////// // Hide the answer element in boilerplate questions $( 'div.boilerplate td.answer' ).parent().hide(); // Hide the question text elements in non-boilerplate questions $('div.questionCell td.questiontext').parent().hide(); // Push the question tables to 100% $( 'div.inlineRow table' ).css({ 'width': '100%' }); // Get everything to line up nicely vertically $( '.inlineQuestion td.questiontext, .inlineQuestion td.answer p' ).css({ 'text-align': 'center' }); // Adjust cell heights so everything lines up nicely horizontally $( '.inlineQuestion td.answer, .inlineQuestion td.questiontext' ).css({ 'height':'35px', 'overflow':'hidden', 'padding':'0.5em' }); $( '#inlineWrapper0 .inlineQuestion' ).css({ 'height':'50px' }); $( '#inlineWrapper0 td.questiontext' ).css({ 'height':'50px' }); // Yes-no question styles $( 'div.yes-no ul' ).css({ 'text-align': 'center', 'font-size': '90%', 'margin': '0', 'padding-bottom': '5px' }); $( 'div.yes-no li' ).css({ 'padding-right': '1.5em' }); $( 'div.yes-no td.answer' ).css({ 'padding-bottom': '0' }); // Short-text question styles $( 'div.text-short input' ).css({ 'width': '125px', 'margin-left': '0' }); // Numeric question styles $( 'div.numeric input' ).css({ 'width': '125px', 'margin-left': '0' }); $( 'div.numeric p.tip' ).css({ 'display': 'none' }); // Get rid of the margins around select boxes $( 'p.question' ).css({ 'margin':'0' }); } } </script>
if(rowNum <= rows && i >= startQuestion-1) {
if(rowNum <= rows-1 && i >= startQuestion-1) {
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var qText = 18a; var qArray = 18b; // Fix the width of the survey $( 'table.outerframe' ).css({'width': '900px'}); // Wrap the 2 questions in a container div and style it $('#question'+qText+', #question'+qArray+'').wrapAll('<div class="inlineWrapper" />'); $('.inlineWrapper').append('<div style="clear:both" />'); $('.inlineWrapper').css({ 'width': '75%', 'margin':'0 auto 10px auto', 'background-color':'#FFFFFF' }); $('.inlineWrapper *').css({ 'padding': '0', 'margin':'0' }); // Hide the question and the help text $('#question'+qText+' td.questiontext, #question'+qArray+' td.questiontext').parent().hide(); $('#question'+qText+' > table:eq(1), #question'+qArray+' > table:eq(1)').hide(); $('#question'+qText+' td.survey-question-help, #question'+qArray+' td.survey-question-help').parent().hide(); //Hide the answer cell of the array $('#question'+qArray+' table.question thead tr').children(":first").hide(); $('#question'+qArray+' table.question tbody tr').children(":first").hide(); $('#question'+qArray+' col').attr('width', ''); // Push all question tables to 100% $('#question'+qText+' table, #question'+qArray+' table').css({'width': '100%'}); // Get the 2 questions to sit politely side by side $('#question'+qText+', #question'+qArray+'').css({'float':'left'}); $('#question'+qText+'').css({'padding':'15px 0 5px 25px'}); $('#question'+qText+'').css({'padding-top':'27px'}); // Adjust here for wrapped array labels $('#question'+qArray+'').css({'padding':'5px 0 10px 0'}); $('#question'+qArray+' table.question td').css({'padding':'4px'}); $('#question'+qText+' table:first').attr('align', 'left'); $('#question'+qText+' label').css({ 'display':'inline', 'width':'auto', 'margin-right':'10px' }); // Set the widths of the 2 questions $('#question'+qText+'').css({'width': '35%'}); $('#question'+qArray+'').css({'width': '58%'}); }); </script>