- Posts: 5
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Assign column-specific classes $('table.subquestion-list tr', thisQuestion).each(function(i) { $('> *:gt(0)', this).each(function(i){ $(this).addClass('column-'+(i+1)); $(this).attr('data-column', i+1); }); }); // Resize the inputs $('.column-1 input[type="text"]', thisQuestion).css('width', 'auto').attr('size', '10'); $('.column-2 input[type="text"]', thisQuestion).css('width', 'auto').attr('size', '5'); }); </script>
Where do I place the script?
tpartner wrote: Set up your survey to use JavaScript and place something like the following script in the source of the question:
Code:<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Assign column-specific classes $('table.subquestion-list tr', thisQuestion).each(function(i) { $('> *:gt(0)', this).each(function(i){ $(this).addClass('column-'+(i+1)); $(this).attr('data-column', i+1); }); }); // Resize the inputs $('.column-1 input[type="text"]', thisQuestion).css('width', 'auto').attr('size', '10'); $('.column-2 input[type="text"]', thisQuestion).css('width', 'auto').attr('size', '5'); }); </script>