I have a dropdown menu where I select a product, then I type two-character code(s) into an input text box I then press submit.
I use a javascript function so when the user types a two-character code the string is separated by a space:
The following code splits the input string of codes if more than one is entered and then inserts each one into a new record into the database.
When I type "A" product code into the input box it will not allow entry so my only problems are: if I type "AA B" it adds two records for AA, AA?
How do I make this so it only adds one AA?
Also, If the product code is already in the database table, how do I stop adding a duplicate?
Thanks.
Ah dinnae ken...
I use a javascript function so when the user types a two-character code the string is separated by a space:
Code:
what.value=what.value.replace(/ /g,'').replace(/(..)/g,'$1 ')
The following code splits the input string of codes if more than one is entered and then inserts each one into a new record into the database.
Code:
<%
Dim response_to_split, split_array
Dim one, two
response_to_split = Request.Form("Size")
split_array = Split(response_to_split, " ")
one = split_array(0)
two = split_array(1)
value = rtrim(Request.Form("ProductCode"))
val = split(value," ")
For i = 0 to Ubound(val)
if len(val(i))=2 then
sql = "INSERT INTO Product ([BusinessID], [Product Code], [Product Type] )"
sql = sql & " VALUES "
sql = sql & "('" & one & "', '" & val(i) & "', '" & "Product Code " & val(i) & " for company " & two & "')"
end if
Set rs = obj_CN.Execute(sql, adBoolean)
Next
%>
When I type "A" product code into the input box it will not allow entry so my only problems are: if I type "AA B" it adds two records for AA, AA?
How do I make this so it only adds one AA?
Also, If the product code is already in the database table, how do I stop adding a duplicate?
Thanks.
Ah dinnae ken...