Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > dynamic multiple select list not selecting properly

Reply
Thread Tools

dynamic multiple select list not selecting properly

 
 
Chris
Guest
Posts: n/a
 
      04-23-2004
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>
 
Reply With Quote
 
 
 
 
Alan Howard
Guest
Posts: n/a
 
      04-24-2004
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

"Chris" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> 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>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop down not selecting properly mark.norgate@gmail.com ASP .Net 2 05-20-2008 04:00 PM
clicking on popup after selecting an item in select list Vikash Kumar Ruby 2 12-20-2006 08:39 AM
Selecting all items in a multiple select: inconsistency with Internet Explorer james.dixon@canberra.edu.au Javascript 3 09-07-2005 01:31 AM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM
More American Graffiti: Properly Framed, Properly Scored? Scot Gardner DVD Video 0 09-02-2003 02:28 AM



Advertisments