Whenever I click on the "Generate ID" button, it currently displays the date '2013-06-13' in a text box. What I really want is for this generated date to have a 4-digit counter appended to it, like '2013-06-13-xxxx' where 'xxxx' represents numbers incrementing from 0001, 0002, and so on. Essentially, when I click on the "Generate ID" button, the output should be '2013-06-13-0001', then upon hitting submit, the form resets. Subsequently clicking on the "Generate ID" button again should display '2013-06-13-0002'. Can someone provide me with the necessary code to achieve this functionality?
var counter = 0000;
function Counter() {
if(document.getElementById("generateid").clicked == true) {
Counter++
return counter;
}
}
This is the code that will generate the desired output:
function guidGenerator() {
var theID = (Year() + "-" + Month() + "-" + Day() + "-" + Counter);
return theID;
}