Welcome, Guest
Username: Password: Remember me

TOPIC: Text limitations on Array (text) Question types

Text limitations on Array (text) Question types 3 years 5 months ago #58979

  • Aasifdevos
  • Aasifdevos's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
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]
The administrator has disabled public write access.

Re: Text limitations on Array (text) Question types 3 years 5 months ago #58984

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4185
  • Thank you received: 785
  • Karma: 359
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Text limitations on Array (text) Question types 3 years 5 months ago #58985

  • Aasifdevos
  • Aasifdevos's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
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
The administrator has disabled public write access.

Re: Text limitations on Array (text) Question types 3 years 5 months ago #58987

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4185
  • Thank you received: 785
  • Karma: 359
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Text limitations on Array (text) Question types 3 years 5 months ago #58990

  • Aasifdevos
  • Aasifdevos's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
Yes
The administrator has disabled public write access.

Re: Text limitations on Array (text) Question types 3 years 5 months ago #59012

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4185
  • Thank you received: 785
  • Karma: 359
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Text limitations on Array (text) Question types 3 years 5 months ago #59034

  • Aasifdevos
  • Aasifdevos's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
Thank you:)
The administrator has disabled public write access.

Re: Text limitations on Array (text) Question types 3 years 5 months ago #59040

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4185
  • Thank you received: 785
  • Karma: 359
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 3 years 5 months ago by tpartner.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.104 seconds
Donation Image