Forums
This topic is locked
Auto number with order
Posted 18 Feb 2002 06:00:44
1
has voted
18 Feb 2002 06:00:44 Steve Copelin posted:
i've developed a shopping cart, but i stuck on creating a unique number system that can be allocated as a order number. i'ver thought of using a asp hit counter but returning visitor may get a duplicate. Anyone have a suggestion or an idea.portfox
Replies
Replied 18 Feb 2002 14:16:17
18 Feb 2002 14:16:17 Owen Eastwick replied:
What database are you using?
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 18 Feb 2002 15:52:55
18 Feb 2002 15:52:55 Andy Smith replied:
I've used this method to get a 9 digit unique id variable.
Perhaps this helps?
<%
Function gen_key(digits)
dim char_array(50)
char_array(0) = "-"
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
char_array(10) = "A"
char_array(11) = "B"
char_array(12) = "C"
char_array(13) = "D"
char_array(14) = "E"
char_array(15) = "F"
char_array(16) = "G"
char_array(17) = "H"
char_array(18) = "I"
char_array(19) = "J"
char_array(20) = "K"
char_array(21) = "L"
char_array(22) = "M"
char_array(23) = "N"
char_array(24) = "A"
char_array(25) = "P"
char_array(26) = "Q"
char_array(27) = "R"
char_array(28) = "S"
char_array(29) = "T"
char_array(30) = "U"
char_array(31) = "V"
char_array(32) = "W"
char_array(33) = "X"
char_array(34) = "Y"
char_array(35) = "Z"
randomize
do while len(output) < digits
num = char_array(Int((35 - 0 + 1) * Rnd + 0))
output = output + num
loop
gen_key = output
End Function
%>
<%myvariable = gen_key(9)%>
Could also be a session variable.
Change the gen_key figure for more or less digits.
N.B. Some of the array has been changed (e.g A instead of O) so that the final output can not be confused for other characters
Edited by - visionuk on 18 Feb 2002 15:59:02
Perhaps this helps?
<%
Function gen_key(digits)
dim char_array(50)
char_array(0) = "-"
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
char_array(10) = "A"
char_array(11) = "B"
char_array(12) = "C"
char_array(13) = "D"
char_array(14) = "E"
char_array(15) = "F"
char_array(16) = "G"
char_array(17) = "H"
char_array(18) = "I"
char_array(19) = "J"
char_array(20) = "K"
char_array(21) = "L"
char_array(22) = "M"
char_array(23) = "N"
char_array(24) = "A"
char_array(25) = "P"
char_array(26) = "Q"
char_array(27) = "R"
char_array(28) = "S"
char_array(29) = "T"
char_array(30) = "U"
char_array(31) = "V"
char_array(32) = "W"
char_array(33) = "X"
char_array(34) = "Y"
char_array(35) = "Z"
randomize
do while len(output) < digits
num = char_array(Int((35 - 0 + 1) * Rnd + 0))
output = output + num
loop
gen_key = output
End Function
%>
<%myvariable = gen_key(9)%>
Could also be a session variable.
Change the gen_key figure for more or less digits.
N.B. Some of the array has been changed (e.g A instead of O) so that the final output can not be confused for other characters
Edited by - visionuk on 18 Feb 2002 15:59:02
Replied 18 Feb 2002 22:03:25
18 Feb 2002 22:03:25 Dennis van Galen replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
i've developed a shopping cart, but i stuck on creating a unique number system that can be allocated as a order number. i'ver thought of using a asp hit counter but returning visitor may get a duplicate. Anyone have a suggestion or an idea.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Make a table in your Dbase with Ordernumbers.
This has 2 columns, OnlyRecord = Unique ID
and a NextOrderNr = Integer$
We use the "Get Unique ID from Table" that comes with the shopping cart, what this behavior does is this:
It gets the value from the NextOrderNr column amd puts it in a Session Variable (you have to name it);
This value is increased with one ( = NextOrderNr);
The old value in the Column gets replaced by this new value, for the next order.
The "Get Unique ID From Table" function is applied on the same page OR a page that precedes the page where the "Add Cart to Table" function is used. Personally, I use it on the same page because if the Session variable allready exists, it won't get a new one.
Just remember to clear the variable after confirmation of the order, or the user won't get a new ID if he places another order without logging out !
Just add, on your order confirmation page, something resembling:
<% Session("svOrderID" = null; %>
Offcourse replacing the svOrderID with the name of your OrderID session...
I hope that helps you out.
With kind regards,
Dennis van Galen
Webmaster KPN Nederland
Financial and Information Services
i've developed a shopping cart, but i stuck on creating a unique number system that can be allocated as a order number. i'ver thought of using a asp hit counter but returning visitor may get a duplicate. Anyone have a suggestion or an idea.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Make a table in your Dbase with Ordernumbers.
This has 2 columns, OnlyRecord = Unique ID
and a NextOrderNr = Integer$
We use the "Get Unique ID from Table" that comes with the shopping cart, what this behavior does is this:
It gets the value from the NextOrderNr column amd puts it in a Session Variable (you have to name it);
This value is increased with one ( = NextOrderNr);
The old value in the Column gets replaced by this new value, for the next order.
The "Get Unique ID From Table" function is applied on the same page OR a page that precedes the page where the "Add Cart to Table" function is used. Personally, I use it on the same page because if the Session variable allready exists, it won't get a new one.
Just remember to clear the variable after confirmation of the order, or the user won't get a new ID if he places another order without logging out !
Just add, on your order confirmation page, something resembling:
<% Session("svOrderID" = null; %>
Offcourse replacing the svOrderID with the name of your OrderID session...
I hope that helps you out.
With kind regards,
Dennis van Galen
Webmaster KPN Nederland
Financial and Information Services