- Posts: 5
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
7 years 8 months ago #139936
by elevia
Defining each column width in Array (Text) questions was created 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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
7 years 8 months ago #139958
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Defining each column width in Array (Text) questions
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
7 years 8 months ago #139982
by elevia
Replied by elevia on topic Defining each column width in Array (Text) questions
Thanks Tony,
it's quite simple and it works!
Marco
it's quite simple and it works!
Marco
The topic has been locked.
- mortisha
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
4 years 11 months ago #183533
by mortisha
Replied by mortisha on topic Defining each column width in Array (Text) questions
Where do I place the script?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
4 years 11 months ago #183534
by holch
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.
Replied by holch on topic Defining each column width in Array (Text) questions
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.
- haroldrio
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 2
4 years 9 months ago #186248
by haroldrio
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.
Replied by haroldrio on topic Defining each column width in Array (Text) questions
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 9 months ago #186252
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Defining each column width in Array (Text) questions
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.
- Vinicos
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
4 years 2 days ago #197122
by Vinicos
Replied by Vinicos on topic Defining each column width in Array (Text) questions
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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
4 years 2 days ago #197123
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Defining each column width in Array (Text) questions
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?
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.
- Vinicos
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
4 years 2 days ago #197132
by Vinicos
Replied by Vinicos on topic Defining each column width in Array (Text) questions
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 2 days ago #197134
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Defining each column width in Array (Text) questions
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Vinicos
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
4 years 2 days ago #197135
by Vinicos
Replied by Vinicos on topic Defining each column width in Array (Text) questions
Found it!
It's the 3.17.7 version!
It's the 3.17.7 version!
The topic has been locked.