Home > WebEOC > Admin Guide > Board Building Tips > Capture Field History with AppendTimeStamp

Capture Field History with AppendTimeStamp

Table of contents
No headers

The below is one example of how to capture history of a field with the <AppendTimeStamp> attribute. See W3Schools for more information on HTML DOM Events: http://www.w3schools.com/jsref/dom_obj_event.asp.

function AppendTimeStamp()
{
var orgRecord = document.forms[0].description.value;
var newRecord = document.forms[0].description_update.value;
var stamp = '\r\n - <value-of select=" /data/@positionname"/> - <value-of select=" /data/@username"/> at <currenttime/> on <currentdate/>\r\n\r\n';
if (document.forms[0].description_update.value != "")

//  Below appends the newest information to the bottom
document.forms[0].description.value = orgRecord + newRecord + stamp;

//  Below appends the newest information to the top
//  document.forms[0].description.value = newRecord + stamp + orgRecord;
/*  By default the newest information will append to the bottom of the original record. 
If it is desired to append the newest information to the top of the original record,
delete the "//" in front of document.forms[0].description.value = newRecord + stamp + orgRecord;
then add "//" to the beginning of document.forms[0].description.value = orgRecord + newRecord + stamp;
*/
document.forms[0].description_update.value = ''; //clears the field
}

function SetSubmitHandler()
{
  document.forms[0].onsubmit = AppendTimeStamp; //this calls the function on save
}

window.onload = SetSubmitHandler; /* this is necessary for SetSubmitHandler() to run. YOU MAY ONLY HAVE 1 
window.onload per board view. */
You must to post a comment.
Last modified

Tags

Classifications

This page has no classifications.