The LimeSurvey Fund-Raiser 2012 is complete. Thank you for donating a total of 25,000 USD!     List of donors »

Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Text limitations on Array (text) Question types

Text limitations on Array (text) Question types 2 years 1 month 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 2 years 1 month ago #58984

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2858
  • Thank you received: 424
  • Karma: 244
Your screenshot didn't work. Could you explain more about what you want to accomplish?
Cheers,
Tony

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 2 years 1 month 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 2 years 1 month ago #58987

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2858
  • Thank you received: 424
  • Karma: 244
By "fixed width", do you mean set a maximum number of characters allowed?
Cheers,
Tony

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 2 years 1 month 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 2 years 1 month ago #59012

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2858
  • Thank you received: 424
  • Karma: 244
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

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 2 years 1 month 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 2 years 1 month ago #59040

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2858
  • Thank you received: 424
  • Karma: 244
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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 2 years 1 month ago by tpartner.
The administrator has disabled public write access.
  • Page:
  • 1
Moderators: DenisChenu, ITEd
Time to create page: 0.226 seconds
Donation Image