Im trying to generate a Unique ID which can be used as an order number for a form submission made in coffee cup form builder.

I contacted coffee cup already and was informed that there's no way to generate unique numbers within form builder, so I've been attempting to do this within the invoice script which is generated after the form is submitted.

It doesn't matter so much what the ID is made up of, I was planning to use a 10 digit code generated from the following:

<script LANGUAGE="Javascript">
var stampmonths = new Array( "01","02","03","04","05","06","07","08","09","10", "11","12");
var thedate = new Date();
document.write(stampmonths[ thedate.getMonth()] + "" + thedate.getDate() + "" + thedate.getFullYear() + thedate.getSeconds() + "" );
</script>

To create: MonthDayYearSecond ... e.g. 0820201450
Which would be perfectly sufficient - in that it's very unlikely the Unique ID will repeat its self in any given day.



When previewing the script for the invoice this works perfectly. I did however begin to wonder when the invoice is sent by email will the script create a "stamp" for the given snapshot in time the invoice was generated, or will it keep updating and pull off newly generated numbers each time its viewed? On testing in an email it appears that no numbers at all have been generated, it just hasn't worked. Maybe the Email programme only supports basic html

My question is, is there a fairly simply way to generate a unique ID, which won't update its self over time?
It needs to be generated at the same time the invoice is generated. It doesn't matter what it consists of, but it does have to to unique