[thelist] ASP, me be puzzled once again

Elfur Logadottir elfur at lists.evolt.org
Mon Feb 5 07:40:37 CST 2001


I'm sorry if this is a duplicate.

I wrote the letter, sent it, but have it nowhere, not in my
outbox, not in my sent items, not in my "thelist" folder -
nowhere. Since I really need any suggestions, I chose to
write it again.

The problem is that I'm trying to compare a field that
contains multiple entries with a lookup table.

I have a two-column table "cat" with records (id, name) I'm
displaying them in an <option> tag with a "do while" loop,
since I don't know the quantity of records. - no problem so
far.

I also have a more-column table "display" again with records
and one of the columns contains values referencing the "cat"
table, but these are multiple values so I have to isolate
each and every one, using a "do while" loop. - again: no
problem so far.

What I now have to do, is to apply a "selected" attribute to
the <option> tag in the "cat" table, to those values that
are displayed in the cat field of the "display" table.
- you with me so far? not really sure if I am, but here is
where the problem kicks in.

below are three code parts, one for the looping of the "cat"
table, another for the looping of isolating the values in
the "display" table, and the third, a lousy attempt to
combine the two, obviously not working, otherwise I wouldn't
be writing.

all help gladly appreciated.

######   FIRST CODE   ######
do while not objRS2.eof
 Response.write "<option"
 if strVefur> "" then
  if Cint(objRS2("id")) = cint(strVefur) then Response.Write
" selected "
 end if
 Response.Write " value=" & objRS2("id")& ">"&
objRS2("name")& "</option>"
 objRS2.movenext
loop


######   SECOND CODE   ######
do While  len(strSelect) > 0
 if instr(strSelect, ",") > 0 then
  intEnd = instr(strSelect, ",")
  strVar = mid(strSelect, 1, intEnd-1)
 else
  strVar = strSelect
 end if
 Response.Write("strVar = " & strVar & "<br>")
 strSelect = mid(strSelect, intEnd+1, len(strSelect))
 Response.Write("strSelect = " & strSelect & "<br>")
Loop

######   THIRD CODE (COMBINED)   ######

do while not objRS2.eof
 if instr(strSelect, ",") > 0 then
  intEnd = instr(strSelect, ",")
  strVar = mid(strSelect, 1, intEnd-1)
 else
  strVar = strSelect
 end if

 Response.Write("strVar = " & strVar & "<br>")
 strSelect = mid(strSelect, intEnd+1, len(strSelect))
 Response.Write("strSelect = " & strSelect & "<br>")

 strID = objRS2("id")
 Response.write "<option"
 if strVar > "" then
  if Cint(strID) = cint(strVar) then Response.Write "
selected "
 end if

 Response.Write " value=" & strID & ">"& objRS2("short")&
" - " & objRS2("name")& "</option>"
 objRS2.movenext
loop


[elfur]





More information about the thelist mailing list