dynamic multiple select list not selecting properly

C

Chris

Hi,
I have a multiple select list I use to display categories with. Each
product can have multiple categories. So I used a multiple select
list to accomplish this. The comma delimited string is then split and
each value is stored in the database separately. The problem is in
order to edit this product I have to display the product's chosen
categories somehow. I chose a multiple select list to do this. And
it won't select anything. What it's supposed to do is this - Loop
through the rsCats recordset to populate the select list, then within
that loop, loop through the rsCheck recordset to see if any of the
values match the rsCats recordset, if it matches output "selected".
The code I used is below:

<form>
<select name="CatID" size="8" multiple>
<%
'populate the multiple list
do until rsCats.eof
intValue=rsCats("dc_CatID")
strName=rsCats("dc_CatName")
intFlag=0
'loop through the recordset to see if values match
do until rsCheck.eof or intFlag=1
if intValue=rsCheck("cad_CatID") then
strSelected=" selected"
intFlag=1
else
strSelected=" not" 'this is to see the html output
end if
rsCheck.movenext()
loop
%>
<option value="<%=intValue%>"<%=strSelected%>><%=strName%></option>
<%
rsCats.movenext()
loop
%>
</select>
</form>
 
A

Alan Howard

I've seen these comparisons fail if your variants have different subtypes.
Try assigning rsCheck("cad_CatID") to a local variable and then echoing out
the types of the two variables in question, intValue and the new one, to
see - use TypeName(). If this is the problem then cast the two to a common
subtype before comparing, CStr or CLng for example.

Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top