HighDots Forums  

Create unique number function

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Create unique number function in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rhonda
 
Posts: n/a

Default Create unique number function - 09-16-2005 , 11:41 AM






Hello all
I'm trying to create a unique order number in a HTML form.(no DB backend)

I found a function that looks promising, but I don't have the JavaScript
know-how to get it working:

function CreateOrderNr()
{dt=newDate();//getstoday'sdaterightnow(tothemillisecond)year=dt.g etFullYear
();month=String(dt.getMonth()+1);if(month.length<2 ){
month="0"+month;}qMaxOrderNr="selectmax(ID_Order)f romtOrder";varmaxorder=DBv
erbinding.execute(qMaxOrderNr);order=maxorder(0)+1 );OrderNr=year+
month+order;return(OrderNr);}//

Taking out any DB element(s), this looks like it could be modified to
produce a unique number. Then I can set it equal to a variable, and to a
HTML Input Name on my form.

Any revision suggestions would really get me out of a jamb.

Thanks




Reply With Quote
  #2  
Old   
Rhonda
 
Posts: n/a

Default Re: Create unique number function - 09-16-2005 , 07:58 PM






"Rhonda" <nomailplease (AT) yahoo (DOT) com> wrote

Quote:
Hello all
I'm trying to create a unique order number in a HTML form.(no DB backend)

I found a function that looks promising, but I don't have the JavaScript
know-how to get it working:

function CreateOrderNr()

{dt=newDate();//getstoday'sdaterightnow(tothemillisecond)year=dt.g etFullYear
();month=String(dt.getMonth()+1);if(month.length<2 ){

month="0"+month;}qMaxOrderNr="selectmax(ID_Order)f romtOrder";varmaxorder=DBv
erbinding.execute(qMaxOrderNr);order=maxorder(0)+1 );OrderNr=year+
month+order;return(OrderNr);}//

Taking out any DB element(s), this looks like it could be modified to
produce a unique number. Then I can set it equal to a variable, and to a
HTML Input Name on my form.

Any revision suggestions would really get me out of a jamb.

Thanks

Solved it! Found the perfect solution.




Reply With Quote
  #3  
Old   
Jasen Betts
 
Posts: n/a

Default Re: Create unique number function - 10-15-2005 , 06:05 PM



On 2005-09-16, Rhonda <nomailplease (AT) yahoo (DOT) com> wrote:
Quote:
Hello all
I'm trying to create a unique order number in a HTML form.(no DB backend)
if an identical form is served to two people there's no practical way to
ensure that they don't get the same order number.

you can use something based on the time their computer is set to
but like I said there's no guarantee... you could limit your server to only
serving one form every second, but if their computer has the erong time all
bets are off...

if you want them to have unique order numbers you must issue them.
either when they download the form or when they submit it.

if it's ok to work only most of the time use something with plenty of digits
based on the time and/or other operating parameters of their system

Bye.
Jasen


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.