I need to generate unique id numbers on the fly using javascript. In the past, I\'ve done this by creating a number using time. The number would be made up of the four digi
Posting this code snippet here for my own future reference (not guaranteed but satisfactory "unique" enough):
// a valid floating number
window.generateUniqueNumber = function() {
return new Date().valueOf() + Math.random();
};
// a valid HTML id
window.generateUniqueId = function() {
return "_" + new Date().valueOf() + Math.random().toFixed(16).substring(2);
};