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>
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>