Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: pre-fill textfield

pre-fill textfield 5 years 3 months ago #63183

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6433
  • Thank you received: 1438
  • Karma: 560
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.
The administrator has disabled public write access.

pre-fill textfield 5 years 3 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: 5 years 3 months ago by claudio123.
The administrator has disabled public write access.

pre-fill textfield 4 years 5 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.
Time to create page: 1.062 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form