Welcome to the LimeSurvey Community Forum

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

Defining each column width in Array (Text) questions

  • elevia
  • elevia's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 7 months ago #139936 by elevia
Hi all,
I have an Array (Text) question and I wish to set each column/textbox width to a specific number of characters (e.g. 10 chars for column 1, 5 chars for column 2, etc.).

Note: the input of the user may be longer than this width, I don't need to set a maximum input length.

What do you suggest to accomplish this task?

Thanks for your help.

Marco
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 7 months ago #139958 by tpartner
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>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: elevia, haroldrio
The topic has been locked.
  • elevia
  • elevia's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 7 months ago #139982 by elevia
Thanks Tony,
it's quite simple and it works!

Marco
The topic has been locked.
More
4 years 10 months ago #183533 by mortisha
Where do I place the script?
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 10 months ago #183534 by holch

Where do I place the script?


Tony explained that in his post: in the source of the question.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
More
4 years 8 months ago #186248 by haroldrio

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>


Hello everyone.
Hoping if you could help me too.

I am using limesurvey 2.50, I want to have different input box width for each multiple short text subquestions.
I have seen the CSS template method but it only works for "others".
Thanks.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 8 months ago #186252 by tpartner
Please do not double-post. You have asked this question in another topic.

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
3 years 11 months ago #197122 by Vinicos
Hello,

I am trying to use this syntaxes but I failed.
I'm not sure what exactly I need to change in the "Assign column-specific classes" and "Resize the inputs" sections.
It might be something really simple, but it has been really hard to use javascript.

Thanks
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #197123 by holch
Tpartner's example is from 3 years ago. It most probably refers to a totally different version of LS.

What version of LS do you use?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
More
3 years 11 months ago #197132 by Vinicos
I'm using my university's LS. It might be a vert silly question, but where can I check which version they are using?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #197134 by tpartner
Bottom of the admin interface.


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
3 years 11 months ago #197135 by Vinicos
Found it!
It's the 3.17.7 version!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose