adrianjohnson
Programmer
I'm trying to compare what a user types in a text-area on a html form, with Code entries in the database.
The codes in the database could be:
AC100
A8300 ... and so on
The user can type anything in the text-area, but it might contain some of the codes.
E.G.
text-area: "Person ordered AC100, A8300"
I've got a recordset (rsCodes) to grab the codes from the database, and retrieved the data from the form. But, what I want to do is see if the user typed in any of the codes and flag it up.
How I've tried to do it (in simple English) is:
1. Create recordset.
2. Loop through each code.
3. Compare the code to the text-area entry
4. If 3 is the same, do something.
5. Move onto the next code.
Or, in ASP
As you can see, I've tried Instr and strcomp, but neither give me success.
How can I do this?
Many thanks,
Adrian Johnson
The codes in the database could be:
AC100
A8300 ... and so on
The user can type anything in the text-area, but it might contain some of the codes.
E.G.
text-area: "Person ordered AC100, A8300"
I've got a recordset (rsCodes) to grab the codes from the database, and retrieved the data from the form. But, what I want to do is see if the user typed in any of the codes and flag it up.
How I've tried to do it (in simple English) is:
1. Create recordset.
2. Loop through each code.
3. Compare the code to the text-area entry
4. If 3 is the same, do something.
5. Move onto the next code.
Or, in ASP
Code:
rsCodes.MoveFirst
Do While Not rsCodes.EOF
lsCode = rsCodes("CodeID")
lsTreat1 = Ucase(lsTreat) ' From text-area
'If strComp(lsCode, lsTreat1, 1) = 0 Then
If Instr(lsCode, lsTreat1) >=0 Then
' Do something
End If
rsCodes.MoveNext
Loop
As you can see, I've tried Instr and strcomp, but neither give me success.
How can I do this?
Many thanks,
Adrian Johnson