Home > WebEOC > Admin Guide > HTML Conventions > Ticket Number Code

Ticket Number Code

Table of contents
No headers

The following code generates a random number. The current date and time are pulled and this value populates the input field on a board. By default, this code precedes the random number with the text ESi. For example, when the input field is clicked, text similar to ESi-20110310102705 would be displayed.

If you want to modify how this appears, including the text, you can change the first part of the ttl variable that is found toward the end of the code. Either remove the 'ESi-' element all together or, to have each random number start with specific numbers or text that you determine, modify the text within the single quotes.

<script type="text/javascript">
function generateTicketNumber(){
     var dt = new Date();
     var ms = dt.getMilliseconds() + '';
     var hr = dt.getHours() + '';
     var yr = dt.getFullYear() + '';
     var mt = dt.getMonth() + 1 + '';
     var da = dt.getDate() + '';
     var uc = dt.getUTCMilliseconds() + dt.getUTCSeconds() + '';
     var ttl = 'Tkt#-' + yr+mt+da+hr+ms;
     document.forms[0].rndNum.value = ttl;
}
</script>
<input type="text" size="20" value="click me" name="rndNum" onfocus="generateTicketNumber();"></input>

 Edit the above script to use a unique field name or ticket format. Note, however, that you cannot enforce or create a strictly sequential ID number using this code.

You must to post a comment.
Last modified

Tags

Classifications

This page has no classifications.