Welcome to the LimeSurvey Community Forum

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

Change Column Width and Freeze top row of Array Checkbox variant

  • limette123
  • limette123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 3 weeks ago #127254 by limette123
Hi
i`ve got the question type: Array Multi-Flex Numbers Checkbox variant with 15 subquestions on the y-scale and 5 subquestions on the x-scale
Now i want to change the width of the columns and used the following code in the Source Screen (Question ID is 1390; i`ve turned XSS Filter off)

<script>

jQuery(document).ready(function() {

// Get rid of all the widths that the API imposes
$( 'div#question1390 table.question col' ).attr('width', '');
$( 'div#question1390 table.question thead td' ).attr('width', '');

// Define a width for the question table so we can do so for its children
// NOTE: Keep this to 95% or less so IE will behave
$( 'div#question1390 table.question' ).attr('width', '95%');

// Define the column widths
// Add or remove columns and adjust widths as necessary but widths should add up to 100%
// NOTE: Columns must be sequentially numbered starting at 0 - eg, td:eq(0), td:eq(1), td:eq(2).....
$( 'div#question1390 table.question tbody th:eq(0)' ).css({ 'width':'50%' }); // Answer text column
$( 'div#question1390 table.question tbody td:eq(0)' ).css({ 'width':'10%' }); // First answer column
$( 'div#question1390 table.question tbody td:eq(1)' ).css({ 'width':'10%' }); // Second answer column
$( 'div#question1390 table.question tbody td:eq(2)' ).css({ 'width':'10%' }); // Third answer column
$( 'div#question1390 table.question tbody td:eq(3)' ).css({ 'width':'10%' }); // Fourth answer column
$( 'div#question1390 table.question tbody td:eq(4)' ).css({ 'width':'10%' }); // Fifth answer column

// Push the text input widths to 95% of their parent containers
$( 'div#question1390 table.question input[type="text"]' ).css({ 'width':'95%' });

// Align the answer text - feel free to experiment
$( 'div#question1390 table.question tbody th' ).css({'text-align':'center'});
});
</script>

Can someone help me why this doesnt work?
A second question: is it possible to freeze the top row so that the subquestions are always visible?
Many thanks
Sabrina
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 3 weeks ago #127259 by tpartner
1) Why use JavaScript? There is an advanced question setting for this - www.limesurvey.org/manual/Question_type_...h_.28answer_width.29

2) This is not easily implemented but there is a "Repeat headers" setting that may help (doesn't seem to be in the manual yet).

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose