- Posts: 9
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8">
Most workarounds are developed for the default template and may need to be modified for other templates.It did work, but only in the default template.
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Get rid of all the widths that the API imposes $( 'div#questionQQ .answer table.question col' ).attr('width', ''); $( 'div#questionQQ .answer 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#questionQQ .answer 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#questionQQ .answer table.question tbody th:eq(0)' ).css({ 'width':'60%' }); // Answer text column $( 'div#questionQQ .answer table.question tbody td:eq(0)' ).css({ 'width':'20%' }); // First answer column $( 'div#questionQQ .answer table.question tbody td:eq(1)' ).css({ 'width':'20%' }); // Second answer column // Push the text input widths to 95% of their parent containers $( 'div#questionQQ .answer table.question input[type="text"]' ).css({ 'width':'95%' }); // Align the answer text - feel free to experiment $( 'div#questionQQ .answer table.question tbody th' ).css({'text-align':'center'}); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Get rid of all the widths that the API imposes $( 'div#question198 table.question col' ).attr('width', ''); $( 'div#question198 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#question198 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#question198 table.question tbody th:eq(0)' ).css({ 'width':'20%' }); // Answer text column $( 'div#question198 table.question tbody td:eq(0)' ).css({ 'width':'25%' }); // First answer column $( 'div#question198 table.question tbody td:eq(1)' ).css({ 'width':'40%' }); // Second answer column $( 'div#question198 table.question tbody td:eq(2)' ).css({ 'width':'15%' }); // Third answer column // Push the text input widths to 95% of their parent containers $( 'div#question198 table.question input[type="text"]' ).css({ 'width':'95%' }); // Align the answer text - feel free to experiment $( 'div#question198 table.question tbody th' ).css({'text-align':'center'}); }); </script>
$( 'div#question198 table.question tbody th' ).css({'text-align':'center'});
$( 'div#question198 table.question tbody th' ).css({ 'text-align':'center' });
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Get rid of all the widths that the API imposes $( 'div#question{QID} table.question col' ).attr('width', ''); $( 'div#question{QID} 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#question{QID} 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#question{QID} table.question tbody th:eq(0)' ).css({ 'width':'20%' }); // Answer text column $( 'div#question{QID} table.question tbody td:eq(0)' ).css({ 'width':'25%' }); // First answer column $( 'div#question{QID} table.question tbody td:eq(1)' ).css({ 'width':'40%' }); // Second answer column $( 'div#question{QID} table.question tbody td:eq(2)' ).css({ 'width':'15%' }); // Third answer column // Push the text input widths to 95% of their parent containers $( 'div#question{QID} table.question input[type="text"]' ).css({ 'width':'95%' }); // Align the answer text - feel free to experiment $( 'div#question{QID} table.question tbody th' ).css({'text-align':'center'}); }); </script>
I'd come across that while rereading the manual after upgrading to LimeSurvey 2.00+ but, of course, hadn't realised that this was the problem here... :blush:Since the introduction of Expression Manager, you must leave a space after opening and before closing curly braces or the contents of the brace will be parsed by EM.
// Align the answer text - feel free to experiment $( 'div#question{QID} table.question tbody th' ).css({'text-align':'center'});
{QID} is an Expression Manager variable that returns the question ID - www.limesurvey.org/manual/Expression_Man...#Access_to_Variables...is {QID} a specific JavaScript function?