I am using the following code to insert a time stamp into a text area. My Problem is it removes any data in the text area. I want it to add the time stamp at the end of the data without removing any of the data.
Can anybody help me with this?
<script language=”JavaScript”>
function setStartTimeNow()
{
var d = new Date();
var currYear = d.getFullYear();
var currMonth = d.getMonth() + 1;
var currDate = d.getDate();
var currHour = d.getHours();
var currMin = d.getMinutes();
time = currYear + “-” +
(currMonth < 10 ? “0” : “”) + currMonth + “-” +
(currDate < 10 ? “0” : “”) + currDate + ” ” +
(currHour < 10 ? “0” : “”) + currHour + “:” +
(currMin < 10 ? “0” : “”) + currMin;
theInput = document.getElementById(“startWhen”);
theInput.value = time;
}
</script>
<form>
<textarea cols=”” rows=”” name=”note” id=”startWhen”>keep this data</textarea>
<a onclick=”setStartTimeNow()”>Set timestamp</a>
</form>