Thursday 17 November 2016

how to create a unique id in javascript [ANSWERED]

A recent challenge arose where a client wanted to put a unique order id on their client signup form.

This was to be in javascript and based on both time and a random number. This allowed for a sortable (time based) component followed by a random component.

This is just in case 2 people connect at the same millisecond (unlikely in this case as they have only 500 visitors a day and all would have to login within the same second to get a 50/50 chance of hitting the page at the same time). Comments below if you agree.


Anyway I used stack exchange as my source on this - link below.

Here's the code which was used to put an order id via quantcast




See the Pen LbbNvK by Mark Hopgood (@marknhopgood) on CodePen.


Original stack exchange link http://stackoverflow.com/questions/3231459/create-unique-id-with-javascript

Live version of this code: http://inumberz.com/quantcast/unique.html

Updated version of this code: http://inumberz.com/quantcast/unique2.html

No comments:

Post a Comment