Solved

Appending data to the top line of a text area using javascript

Posted on 2011-03-21
4
358 Views
Last Modified: 2012-05-11
Hi Guys,

thank you for taking the time to look at my question.  Essentially a very simple one I hope.

Essentially I have some text area's, with an onclick event, to add a new line with the time and date, I would like to make this appear at the top of the textarea instead.  

Any assistance would be greatly appreciated.
0
Comment
Question by:mavmanau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
B34RDY earned 250 total points
ID: 35186226
Here is an attempt that achieves what I believe you want:
<html>
<head>
<title>Textarea Test</title>
<script type="text/javascript">
function addDT(fnArea){
	var d=new Date();
	fnArea.value = d+'\n'+fnArea.value;
}
</script>
</head>
<body>
<textarea id="textArea" cols="25" rows="5" onclick="addDT(this);">This is the text that initially appears in the textarea.</textarea>
</body>
</html>

Open in new window

0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 35186233
try this :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
	window.onload = function() {
		var d = new Date();
		d = d.getFullYear() + d2(d.getMonth()) + d2(d.getDate());
		var s = document.getElementById("textareaId").value;
		document.getElementById("textareaId").value = d + "\n" + s;
	}
	function d2(n) { return (n<10)?("0"+n):n; }
</script>
</head>
<body>
<textarea id="textareaId" cols="32" rows="5">12ggf3456sskkflkflks</textarea>
</body>
</html>

Open in new window

0
 

Author Comment

by:mavmanau
ID: 35186244
of course.....I should have thought of that...must be having a worse day than what I thought...lol
0
 

Author Closing Comment

by:mavmanau
ID: 35186424
Thank you for the assist guys!! very much appreciated.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question