Welcome, Guest
Username: Password: Remember me

TOPIC: pre-fill textfield

pre-fill textfield 4 years 4 months ago #63183

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5263
  • Thank you received: 1097
  • Karma: 457
It's not a good idea to use "min" as a variable name because it refers to a JavaScript method. Also, I think you were redefining the variable "Dat".

Try this ( I assume you want to load the current date and time into the textarea in a readable format):
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		var Dat = new Date();
		var minutes = Dat.getMinutes();
		if (minutes <10)
			minutes= "0" + String(minutes); // insert 0, if minutes are <10
		var DatArr = [Dat.getDate(), (Dat.getMonth() + 1), Dat.getFullYear(), Dat.getHours(), minutes];
		var datzeit=DatArr[0] + "." + DatArr[1] + "." + DatArr[2] + " - " + DatArr[3] + ":" + DatArr[4] + " Uhr";
		var QQ = 383; // put the right question number
		$('#question'+QQ+' textarea.textarea').val("Heute ist der "+datzeit); 
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.

pre-fill textfield 4 years 4 months ago #63187

  • claudio123
  • claudio123's Avatar
  • Offline
  • Junior Lime
  • Posts: 31
  • Thank you received: 1
  • Karma: 0

redefining "dat" works well, using "min" as a variable also does the job, it is however confusing, I admit.

Another strange behavior I realized is that the textarea is only filled with the text I want to be displayed, if I define the number of rows of the textarea. If I do not define it, pre-fill text is not displayed. (Took me another hour to find that out...)

And I used the date as an example to pre-fill a text area - it can still be edited while filling the survey but offers the current data - this was just an idea.

AND: I want a preview for forum posts - it would prevent a lot of editing...
... lost in brackets ...
(I suggest a preview option for posting in the forum)
Last Edit: 4 years 4 months ago by claudio123.
The administrator has disabled public write access.

pre-fill textfield 3 years 6 months ago #79765

  • audiolime
  • audiolime's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
That's exactly what I am looking for!
How and where do I add the number of rows for the textarea - could you provide an example of the code you used in the end?
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.137 seconds