[thelist] ASP, me be puzzled once again
lanehol at bellsouth.net
lanehol at bellsouth.net
Mon Feb 5 09:39:37 CST 2001
It seems like strSelect is a comma separated list of integer values from the [id] field, right?
If that is the case then why not rewrite the code to scan strSelect for the current [id] value, such as:
do while not objRS2.eof
strID = objRS2("id")
Response.write "<option"
if instr(strSelect,Trim(Cstr(strID)) > 0 then
Response.Write "selected "
end if
Response.Write " value=" & strID & ">" & objRS2("short") _
& " - " & objRS2("name")& "</option>"
objRS2.movenext
loop
<TIP>Simplify</Tip>
lane
>
> From: "Elfur Logadottir" <elfur at lists.evolt.org>
> Date: 2001/02/05 Mon PM 01:43:13 EST
> To: <thelist at lists.evolt.org>
> Subject: [thelist] ASP, me be puzzled once again
>
> 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]
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !
>
>
More information about the thelist
mailing list