rontooo
03-23-2003, 06:07 AM
I have a web site I want to start selling products at. The site is entirely HTML with no use of any coding functionality other than JS. So far I'm planning to use Mals ecommerece site for the shopping cart aspect of it.
http://www.mals-e.com
To use this site I need to generate a unique "userid". Is using the Math.random() in JS the real only solution? Given the fact I only have JS capabilities at my disposal? My plan (so far) was to generate a number using random() and then set that value in a cookie for persistance or "session" purposes. Is this the best approach? The only approach?
Here's the code I was thinking of using...
function createUserID() {
var myNum = 0;
var myMax = 1000000;
do {
myNum = Math.floor(Math.random() * myMax);
alert(myNum);
} while(myNum < 100000 || myNum >= 1000000);
return myNum;
}
http://www.mals-e.com
To use this site I need to generate a unique "userid". Is using the Math.random() in JS the real only solution? Given the fact I only have JS capabilities at my disposal? My plan (so far) was to generate a number using random() and then set that value in a cookie for persistance or "session" purposes. Is this the best approach? The only approach?
Here's the code I was thinking of using...
function createUserID() {
var myNum = 0;
var myMax = 1000000;
do {
myNum = Math.floor(Math.random() * myMax);
alert(myNum);
} while(myNum < 100000 || myNum >= 1000000);
return myNum;
}