Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-21
4
Medium Priority
?
364 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 1000 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 1000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
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)

618 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