Check out the LimeSurvey source code on GitHub!

Text limitations on Array (text) Question types

More
5 years 10 months ago #58979 by Aasifdevos
Hi, could anyone tell me if it is possible to set text limitations on each individual input field with the Array (text) question type? if not could you please advise?
[attachment:1]C:\fakepath\Survey question.jpg[/attachment]

Please Log in to join the conversation.

More
5 years 10 months ago #58984 by tpartner
Your screenshot didn't work. Could you explain more about what you want to accomplish?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
5 years 10 months ago #58985 by Aasifdevos
Hi Tony,

I have 5 sub question for this question, for 2 of the subquestion i would like to make it fixed width. I have tried making the question fixed width but then it makes all the subquestion fixed width. Any idea as to what i could do? If you want i could email the screen shot to you.
Regards
Aasif

Please Log in to join the conversation.

More
5 years 10 months ago #58987 by tpartner
By "fixed width", do you mean set a maximum number of characters allowed?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
5 years 10 months ago #58990 by Aasifdevos
Yes

Please Log in to join the conversation.

More
5 years 10 months ago #59012 by tpartner
Then I would use JavaScript to add a "maxlength" attribute to the inputs.

I'll put together a small snippet for you this evening.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
5 years 10 months ago #59034 by Aasifdevos
Thank you:)

Please Log in to join the conversation.

More
5 years 10 months ago - 5 years 10 months ago #59040 by tpartner
Set up your survey to use JavaScript and place the following script in the source of the array question.

Replace the following parameters in row 5:
- QQ = array question ID
- RR = row number to have maxlength applied
- NN = maxlength value
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		// Call the function with the question ID, row number and maxlength value
		setLength(QQ, RR, NN);
 
		// A function to set a maxlength attribute for text inputs in an array
		function setLength(qID, rowNum, maxLength) {
 
			var rowIndex = rowNum - 1;
 
			$('#question'+qID+' table.question tbody:eq('+rowIndex+') input[type=text]').attr('maxlength', maxLength);
 
		}
 
	});
 
</script>

The call can be repeated for more rows. So, for example, the following calls would set a maxlength of 3 for row 2 inputs and a maxlength of 10 for row 4 inputs.
		// Call the function with the question ID, row number and maxlength value
		setLength(12345, 2, 3);
		setLength(12345, 4, 10);

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 10 months ago by tpartner.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form