How to extract multiple records (rows) from one recordset -- now for listbox 
Author Message
 How to extract multiple records (rows) from one recordset -- now for listbox

Well, I still need help with this issue now for <select multiple> list box.
I can't really use AbsolutePosition, cause I never know how many records for
each user there will be.
So here is my question: How can I populate a listbox from one table AND keep
multiple values selected  according user's information from another table?
My code so far will  select only one field which is match for first record
in rsJsSelect.Fields("RegionID"). I know that I suppose to somehow

<Get the value you want to select first. Compare this value to the value of
<each option and add the "selected" attribute to the option if they are
equal...

But I can not really find any examples how to do this and I don't know yet
how to do it by myself... Please help.

Thanks a lot in advance.
George L.

<%
set rsRegions = Server.CreateObject("ADODB.Recordset")
rsRegions.ActiveConnection = MYDBOCONNECTION
rsRegions.Source = "SELECT RegionID, Description FROM Regions ORDER BY CASE
WHEN RegionID < 9000  THEN 2 ELSE 1 END, RegionID"
rsRegions.CursorType = 0
rsRegions.CursorLocation = 2
rsRegions.LockType = 3
rsRegions.Open()
rsRegions_numRows = 0
%>
<%
set rsJsSelect = Server.CreateObject("ADODB.Recordset")
rsJsSelect.ActiveConnection = MYDBOCONNECTION
rsJsSelect.Source = "SELECT RegionsCandidates.CandidateID,
RegionsCandidates.RegionID FROM RegionsCandidates WHERE
RegionsCandidates.CandidateID=280"
rsJsSelect.CursorType = 0
rsJsSelect.CursorLocation = 2
rsJsSelect.LockType = 3
rsJsSelect.Open()
rsJsSelect_numRows = 0
%>

<html>
<body>
<form>
<select name="Regions" size="5" multiple>
<%
While NOT rsRegions.EOF
    If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID") Then  %>

<option selected
value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
%></option>

<%
 Else
%>
<option
value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
%></option>
<%
  End If
 rsRegions.MoveNext
 Wend
 If (rsRegions.CursorType > 0) Then
  rsRegions.MoveFirst
 Else
  rsRegions.Requery
 End If
%>
</select>
</form>
</body>
</html>



Fri, 10 Sep 2004 12:03:35 GMT  
 How to extract multiple records (rows) from one recordset -- now for listbox

If you want to use the listbox then :
1. Activate the multiple selection property for the list
2. When adding the items to the list box, set the tag of each item equal to
the recordsets bookmark
3. When the user is finished selecting, just go through the list checking
which items have the selected property set true and set the recordset
bookmark equal to the items tag value.

--
Saludos, Jorge Jimenez, SICAD S.A., Costa Rica


Quote:
> Well, I still need help with this issue now for <select multiple> list
box.
> I can't really use AbsolutePosition, cause I never know how many records
for
> each user there will be.
> So here is my question: How can I populate a listbox from one table AND
keep
> multiple values selected  according user's information from another table?
> My code so far will  select only one field which is match for first record
> in rsJsSelect.Fields("RegionID"). I know that I suppose to somehow

> <Get the value you want to select first. Compare this value to the value
of
> <each option and add the "selected" attribute to the option if they are
> equal...

> But I can not really find any examples how to do this and I don't know yet
> how to do it by myself... Please help.

> Thanks a lot in advance.
> George L.

> <%
> set rsRegions = Server.CreateObject("ADODB.Recordset")
> rsRegions.ActiveConnection = MYDBOCONNECTION
> rsRegions.Source = "SELECT RegionID, Description FROM Regions ORDER BY
CASE
> WHEN RegionID < 9000  THEN 2 ELSE 1 END, RegionID"
> rsRegions.CursorType = 0
> rsRegions.CursorLocation = 2
> rsRegions.LockType = 3
> rsRegions.Open()
> rsRegions_numRows = 0
> %>
> <%
> set rsJsSelect = Server.CreateObject("ADODB.Recordset")
> rsJsSelect.ActiveConnection = MYDBOCONNECTION
> rsJsSelect.Source = "SELECT RegionsCandidates.CandidateID,
> RegionsCandidates.RegionID FROM RegionsCandidates WHERE
> RegionsCandidates.CandidateID=280"
> rsJsSelect.CursorType = 0
> rsJsSelect.CursorLocation = 2
> rsJsSelect.LockType = 3
> rsJsSelect.Open()
> rsJsSelect_numRows = 0
> %>

> <html>
> <body>
> <form>
> <select name="Regions" size="5" multiple>
> <%
> While NOT rsRegions.EOF
>     If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID") Then
%>

> <option selected

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> %></option>

> <%
>  Else
> %>
> <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> %></option>
> <%
>   End If
>  rsRegions.MoveNext
>  Wend
>  If (rsRegions.CursorType > 0) Then
>   rsRegions.MoveFirst
>  Else
>   rsRegions.Requery
>  End If
> %>
> </select>
> </form>
> </body>
> </html>



Fri, 10 Sep 2004 12:51:12 GMT  
 How to extract multiple records (rows) from one recordset -- now for listbox
Thanks, but ??? what do you mean? Forgive me I am really new at this.

Quote:
> 1. Activate the multiple selection property for the list

but it is activated:  <select name="Regions" size="5" multiple>

Quote:
> 2. When adding the items to the list box, set the tag of each item equal
to
> the recordsets bookmark

I am not adding anything, I am populating it from record set:
 <option
value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
%></option>

and finally:

Quote:
> 3. When the user is finished selecting, just go through the list checking
> which items have the selected property set true and set the recordset
> bookmark equal to the items tag value.

I am not even getting to the point where user can select anything. I am
looking for a way how to PRESENT user with a listbox where one OR multiple
values will be selected on page load according what user selected previously
in time (user's info from db). I don't know which values are those or how
many of them, can be one or hundreds of them...Everything suppose to be
dynamic.

Please, if you suggest anything, please be kind provide some code example,
like I said: me=newbie :)
George L.


Quote:

> If you want to use the listbox then :
> 1. Activate the multiple selection property for the list
> 2. When adding the items to the list box, set the tag of each item equal
to
> the recordsets bookmark
> 3. When the user is finished selecting, just go through the list checking
> which items have the selected property set true and set the recordset
> bookmark equal to the items tag value.

> --
> Saludos, Jorge Jimenez, SICAD S.A., Costa Rica



> > Well, I still need help with this issue now for <select multiple> list
> box.
> > I can't really use AbsolutePosition, cause I never know how many records
> for
> > each user there will be.
> > So here is my question: How can I populate a listbox from one table AND
> keep
> > multiple values selected  according user's information from another
table?
> > My code so far will  select only one field which is match for first
record
> > in rsJsSelect.Fields("RegionID"). I know that I suppose to somehow

> > <Get the value you want to select first. Compare this value to the value
> of
> > <each option and add the "selected" attribute to the option if they are
> > equal...

> > But I can not really find any examples how to do this and I don't know
yet
> > how to do it by myself... Please help.

> > Thanks a lot in advance.
> > George L.

> > <%
> > set rsRegions = Server.CreateObject("ADODB.Recordset")
> > rsRegions.ActiveConnection = MYDBOCONNECTION
> > rsRegions.Source = "SELECT RegionID, Description FROM Regions ORDER BY
> CASE
> > WHEN RegionID < 9000  THEN 2 ELSE 1 END, RegionID"
> > rsRegions.CursorType = 0
> > rsRegions.CursorLocation = 2
> > rsRegions.LockType = 3
> > rsRegions.Open()
> > rsRegions_numRows = 0
> > %>
> > <%
> > set rsJsSelect = Server.CreateObject("ADODB.Recordset")
> > rsJsSelect.ActiveConnection = MYDBOCONNECTION
> > rsJsSelect.Source = "SELECT RegionsCandidates.CandidateID,
> > RegionsCandidates.RegionID FROM RegionsCandidates WHERE
> > RegionsCandidates.CandidateID=280"
> > rsJsSelect.CursorType = 0
> > rsJsSelect.CursorLocation = 2
> > rsJsSelect.LockType = 3
> > rsJsSelect.Open()
> > rsJsSelect_numRows = 0
> > %>

> > <html>
> > <body>
> > <form>
> > <select name="Regions" size="5" multiple>
> > <%
> > While NOT rsRegions.EOF
> >     If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID") Then
> %>

> > <option selected

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> > %></option>

> > <%
> >  Else
> > %>
> > <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> > %></option>
> > <%
> >   End If
> >  rsRegions.MoveNext
> >  Wend
> >  If (rsRegions.CursorType > 0) Then
> >   rsRegions.MoveFirst
> >  Else
> >   rsRegions.Requery
> >  End If
> > %>
> > </select>
> > </form>
> > </body>
> > </html>



Fri, 10 Sep 2004 14:05:14 GMT  
 How to extract multiple records (rows) from one recordset -- now for listbox
Well George, let's see if we are talking about the same things:
You are using a standard listbox control, right ?

--
Saludos, Jorge Jimenez, SICAD S.A., Costa Rica


Quote:
> Thanks, but ??? what do you mean? Forgive me I am really new at this.

> > 1. Activate the multiple selection property for the list

> but it is activated:  <select name="Regions" size="5" multiple>

> > 2. When adding the items to the list box, set the tag of each item equal
> to
> > the recordsets bookmark

> I am not adding anything, I am populating it from record set:
>  <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> %></option>

> and finally:
> > 3. When the user is finished selecting, just go through the list
checking
> > which items have the selected property set true and set the recordset
> > bookmark equal to the items tag value.

> I am not even getting to the point where user can select anything. I am
> looking for a way how to PRESENT user with a listbox where one OR multiple
> values will be selected on page load according what user selected
previously
> in time (user's info from db). I don't know which values are those or how
> many of them, can be one or hundreds of them...Everything suppose to be
> dynamic.

> Please, if you suggest anything, please be kind provide some code example,
> like I said: me=newbie :)
> George L.



> > If you want to use the listbox then :
> > 1. Activate the multiple selection property for the list
> > 2. When adding the items to the list box, set the tag of each item equal
> to
> > the recordsets bookmark
> > 3. When the user is finished selecting, just go through the list
checking
> > which items have the selected property set true and set the recordset
> > bookmark equal to the items tag value.

> > --
> > Saludos, Jorge Jimenez, SICAD S.A., Costa Rica



> > > Well, I still need help with this issue now for <select multiple> list
> > box.
> > > I can't really use AbsolutePosition, cause I never know how many
records
> > for
> > > each user there will be.
> > > So here is my question: How can I populate a listbox from one table
AND
> > keep
> > > multiple values selected  according user's information from another
> table?
> > > My code so far will  select only one field which is match for first
> record
> > > in rsJsSelect.Fields("RegionID"). I know that I suppose to somehow

> > > <Get the value you want to select first. Compare this value to the
value
> > of
> > > <each option and add the "selected" attribute to the option if they
are
> > > equal...

> > > But I can not really find any examples how to do this and I don't know
> yet
> > > how to do it by myself... Please help.

> > > Thanks a lot in advance.
> > > George L.

> > > <%
> > > set rsRegions = Server.CreateObject("ADODB.Recordset")
> > > rsRegions.ActiveConnection = MYDBOCONNECTION
> > > rsRegions.Source = "SELECT RegionID, Description FROM Regions ORDER BY
> > CASE
> > > WHEN RegionID < 9000  THEN 2 ELSE 1 END, RegionID"
> > > rsRegions.CursorType = 0
> > > rsRegions.CursorLocation = 2
> > > rsRegions.LockType = 3
> > > rsRegions.Open()
> > > rsRegions_numRows = 0
> > > %>
> > > <%
> > > set rsJsSelect = Server.CreateObject("ADODB.Recordset")
> > > rsJsSelect.ActiveConnection = MYDBOCONNECTION
> > > rsJsSelect.Source = "SELECT RegionsCandidates.CandidateID,
> > > RegionsCandidates.RegionID FROM RegionsCandidates WHERE
> > > RegionsCandidates.CandidateID=280"
> > > rsJsSelect.CursorType = 0
> > > rsJsSelect.CursorLocation = 2
> > > rsJsSelect.LockType = 3
> > > rsJsSelect.Open()
> > > rsJsSelect_numRows = 0
> > > %>

> > > <html>
> > > <body>
> > > <form>
> > > <select name="Regions" size="5" multiple>
> > > <%
> > > While NOT rsRegions.EOF
> > >     If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID")
Then
> > %>

> > > <option selected

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> > > %></option>

> > > <%
> > >  Else
> > > %>
> > > <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> > > %></option>
> > > <%
> > >   End If
> > >  rsRegions.MoveNext
> > >  Wend
> > >  If (rsRegions.CursorType > 0) Then
> > >   rsRegions.MoveFirst
> > >  Else
> > >   rsRegions.Requery
> > >  End If
> > > %>
> > > </select>
> > > </form>
> > > </body>
> > > </html>



Sat, 11 Sep 2004 00:19:59 GMT  
 How to extract multiple records (rows) from one recordset -- now for listbox
I am using multiselect listbox in asp created by HTML <select name=""
size="" multiple> </select> tag...

Actually I think I am getting close, now I can display all required options
selected but in the same time those are only options that visible in
listbox. Where did rest of them go??? I suppose it has something to do with
positioning "NOT rsJsSelect.EOF" and "rsJsSelect.MoveNext" which I added to
the code, but can't seems to find right combination...
Any suggestions?
George L.

<select name="Regions" size="5" multiple>
<%
 While NOT rsRegions.EOF  and NOT rsJsSelect.EOF
  If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID")  Then
 %>
<option selected
value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
%></option>
<%
   Else
%>
<option
value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
%></option>
<%
 End If

 rsRegions.MoveNext
Wend
 If (rsRegions.CursorType > 0) Then
  rsRegions.MoveFirst
 Else
  rsRegions.Requery
 End If
%>
</select>


Quote:
> Well George, let's see if we are talking about the same things:
> You are using a standard listbox control, right ?

> --
> Saludos, Jorge Jimenez, SICAD S.A., Costa Rica



> > Thanks, but ??? what do you mean? Forgive me I am really new at this.

> > > 1. Activate the multiple selection property for the list

> > but it is activated:  <select name="Regions" size="5" multiple>

> > > 2. When adding the items to the list box, set the tag of each item
equal
> > to
> > > the recordsets bookmark

> > I am not adding anything, I am populating it from record set:
> >  <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> > %></option>

> > and finally:
> > > 3. When the user is finished selecting, just go through the list
> checking
> > > which items have the selected property set true and set the recordset
> > > bookmark equal to the items tag value.

> > I am not even getting to the point where user can select anything. I am
> > looking for a way how to PRESENT user with a listbox where one OR
multiple
> > values will be selected on page load according what user selected
> previously
> > in time (user's info from db). I don't know which values are those or
how
> > many of them, can be one or hundreds of them...Everything suppose to be
> > dynamic.

> > Please, if you suggest anything, please be kind provide some code
example,
> > like I said: me=newbie :)
> > George L.



> > > If you want to use the listbox then :
> > > 1. Activate the multiple selection property for the list
> > > 2. When adding the items to the list box, set the tag of each item
equal
> > to
> > > the recordsets bookmark
> > > 3. When the user is finished selecting, just go through the list
> checking
> > > which items have the selected property set true and set the recordset
> > > bookmark equal to the items tag value.

> > > --
> > > Saludos, Jorge Jimenez, SICAD S.A., Costa Rica



> > > > Well, I still need help with this issue now for <select multiple>
list
> > > box.
> > > > I can't really use AbsolutePosition, cause I never know how many
> records
> > > for
> > > > each user there will be.
> > > > So here is my question: How can I populate a listbox from one table
> AND
> > > keep
> > > > multiple values selected  according user's information from another
> > table?
> > > > My code so far will  select only one field which is match for first
> > record
> > > > in rsJsSelect.Fields("RegionID"). I know that I suppose to somehow

> > > > <Get the value you want to select first. Compare this value to the
> value
> > > of
> > > > <each option and add the "selected" attribute to the option if they
> are
> > > > equal...

> > > > But I can not really find any examples how to do this and I don't
know
> > yet
> > > > how to do it by myself... Please help.

> > > > Thanks a lot in advance.
> > > > George L.

> > > > <%
> > > > set rsRegions = Server.CreateObject("ADODB.Recordset")
> > > > rsRegions.ActiveConnection = MYDBOCONNECTION
> > > > rsRegions.Source = "SELECT RegionID, Description FROM Regions ORDER
BY
> > > CASE
> > > > WHEN RegionID < 9000  THEN 2 ELSE 1 END, RegionID"
> > > > rsRegions.CursorType = 0
> > > > rsRegions.CursorLocation = 2
> > > > rsRegions.LockType = 3
> > > > rsRegions.Open()
> > > > rsRegions_numRows = 0
> > > > %>
> > > > <%
> > > > set rsJsSelect = Server.CreateObject("ADODB.Recordset")
> > > > rsJsSelect.ActiveConnection = MYDBOCONNECTION
> > > > rsJsSelect.Source = "SELECT RegionsCandidates.CandidateID,
> > > > RegionsCandidates.RegionID FROM RegionsCandidates WHERE
> > > > RegionsCandidates.CandidateID=280"
> > > > rsJsSelect.CursorType = 0
> > > > rsJsSelect.CursorLocation = 2
> > > > rsJsSelect.LockType = 3
> > > > rsJsSelect.Open()
> > > > rsJsSelect_numRows = 0
> > > > %>

> > > > <html>
> > > > <body>
> > > > <form>
> > > > <select name="Regions" size="5" multiple>
> > > > <%
> > > > While NOT rsRegions.EOF
> > > >     If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID")
> Then
> > > %>

> > > > <option selected

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> > > > %></option>

> > > > <%
> > > >  Else
> > > > %>
> > > > <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> > > > %></option>
> > > > <%
> > > >   End If
> > > >  rsRegions.MoveNext
> > > >  Wend
> > > >  If (rsRegions.CursorType > 0) Then
> > > >   rsRegions.MoveFirst
> > > >  Else
> > > >   rsRegions.Requery
> > > >  End If
> > > > %>
> > > > </select>
> > > > </form>
> > > > </body>
> > > > </html>



Sat, 11 Sep 2004 03:55:23 GMT  
 How to extract multiple records (rows) from one recordset -- now for listbox
Are you debugging your code?? Put in response.write statements to see what's
going on, or preferably use runtime debugging in Visual Interdev

Jeff


Quote:
> I am using multiselect listbox in asp created by HTML <select name=""
> size="" multiple> </select> tag...

> Actually I think I am getting close, now I can display all required
options
> selected but in the same time those are only options that visible in
> listbox. Where did rest of them go??? I suppose it has something to do
with
> positioning "NOT rsJsSelect.EOF" and "rsJsSelect.MoveNext" which I added
to
> the code, but can't seems to find right combination...
> Any suggestions?
> George L.

> <select name="Regions" size="5" multiple>
> <%
>  While NOT rsRegions.EOF  and NOT rsJsSelect.EOF
>   If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID")  Then
>  %>
> <option selected

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> %></option>
> <%
>    Else
> %>
> <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> %></option>
> <%
>  End If

>  rsRegions.MoveNext
> Wend
>  If (rsRegions.CursorType > 0) Then
>   rsRegions.MoveFirst
>  Else
>   rsRegions.Requery
>  End If
> %>
> </select>



> > Well George, let's see if we are talking about the same things:
> > You are using a standard listbox control, right ?

> > --
> > Saludos, Jorge Jimenez, SICAD S.A., Costa Rica



> > > Thanks, but ??? what do you mean? Forgive me I am really new at this.

> > > > 1. Activate the multiple selection property for the list

> > > but it is activated:  <select name="Regions" size="5" multiple>

> > > > 2. When adding the items to the list box, set the tag of each item
> equal
> > > to
> > > > the recordsets bookmark

> > > I am not adding anything, I am populating it from record set:
> > >  <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> > > %></option>

> > > and finally:
> > > > 3. When the user is finished selecting, just go through the list
> > checking
> > > > which items have the selected property set true and set the
recordset
> > > > bookmark equal to the items tag value.

> > > I am not even getting to the point where user can select anything. I
am
> > > looking for a way how to PRESENT user with a listbox where one OR
> multiple
> > > values will be selected on page load according what user selected
> > previously
> > > in time (user's info from db). I don't know which values are those or
> how
> > > many of them, can be one or hundreds of them...Everything suppose to
be
> > > dynamic.

> > > Please, if you suggest anything, please be kind provide some code
> example,
> > > like I said: me=newbie :)
> > > George L.



> > > > If you want to use the listbox then :
> > > > 1. Activate the multiple selection property for the list
> > > > 2. When adding the items to the list box, set the tag of each item
> equal
> > > to
> > > > the recordsets bookmark
> > > > 3. When the user is finished selecting, just go through the list
> > checking
> > > > which items have the selected property set true and set the
recordset
> > > > bookmark equal to the items tag value.

> > > > --
> > > > Saludos, Jorge Jimenez, SICAD S.A., Costa Rica



> > > > > Well, I still need help with this issue now for <select multiple>
> list
> > > > box.
> > > > > I can't really use AbsolutePosition, cause I never know how many
> > records
> > > > for
> > > > > each user there will be.
> > > > > So here is my question: How can I populate a listbox from one
table
> > AND
> > > > keep
> > > > > multiple values selected  according user's information from
another
> > > table?
> > > > > My code so far will  select only one field which is match for
first
> > > record
> > > > > in rsJsSelect.Fields("RegionID"). I know that I suppose to somehow

> > > > > <Get the value you want to select first. Compare this value to the
> > value
> > > > of
> > > > > <each option and add the "selected" attribute to the option if
they
> > are
> > > > > equal...

> > > > > But I can not really find any examples how to do this and I don't
> know
> > > yet
> > > > > how to do it by myself... Please help.

> > > > > Thanks a lot in advance.
> > > > > George L.

> > > > > <%
> > > > > set rsRegions = Server.CreateObject("ADODB.Recordset")
> > > > > rsRegions.ActiveConnection = MYDBOCONNECTION
> > > > > rsRegions.Source = "SELECT RegionID, Description FROM Regions
ORDER
> BY
> > > > CASE
> > > > > WHEN RegionID < 9000  THEN 2 ELSE 1 END, RegionID"
> > > > > rsRegions.CursorType = 0
> > > > > rsRegions.CursorLocation = 2
> > > > > rsRegions.LockType = 3
> > > > > rsRegions.Open()
> > > > > rsRegions_numRows = 0
> > > > > %>
> > > > > <%
> > > > > set rsJsSelect = Server.CreateObject("ADODB.Recordset")
> > > > > rsJsSelect.ActiveConnection = MYDBOCONNECTION
> > > > > rsJsSelect.Source = "SELECT RegionsCandidates.CandidateID,
> > > > > RegionsCandidates.RegionID FROM RegionsCandidates WHERE
> > > > > RegionsCandidates.CandidateID=280"
> > > > > rsJsSelect.CursorType = 0
> > > > > rsJsSelect.CursorLocation = 2
> > > > > rsJsSelect.LockType = 3
> > > > > rsJsSelect.Open()
> > > > > rsJsSelect_numRows = 0
> > > > > %>

> > > > > <html>
> > > > > <body>
> > > > > <form>
> > > > > <select name="Regions" size="5" multiple>
> > > > > <%
> > > > > While NOT rsRegions.EOF
> > > > >     If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID")
> > Then
> > > > %>

> > > > > <option selected

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> > > > > %></option>

> > > > > <%
> > > > >  Else
> > > > > %>
> > > > > <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> > > > > %></option>
> > > > > <%
> > > > >   End If
> > > > >  rsRegions.MoveNext
> > > > >  Wend
> > > > >  If (rsRegions.CursorType > 0) Then
> > > > >   rsRegions.MoveFirst
> > > > >  Else
> > > > >   rsRegions.Requery
> > > > >  End If
> > > > > %>
> > > > > </select>
> > > > > </form>
> > > > > </body>
> > > > > </html>



Sat, 11 Sep 2004 06:12:09 GMT  
 How to extract multiple records (rows) from one recordset -- now for listbox
Don't have Interdev, but here is what I have with response.write:

If  I set rsJsSelect.CursorType = 0
         rsRegions.CursorType = 0

Response.Write rsJsSelect.recordcount: -1
Response.Write rsRegions.recordcount: -1
Response.Write rsJsSelect.Fields("RegionID"): 9997     '*** which is a first
correct record
Response.Write rsRegions.Fields("RegionID"): 9997
Response.Write rsRegions.Fields("Description"): Region1

and if  rsJsSelect.CursorType = 3
            rsRegions.CursorType =3
Response.Write rsJsSelect.recordcount: 3
Response.Write rsRegions.recordcount: 47

Response.Write rsJsSelect.Fields("RegionID"): 9997
Response.Write rsRegions.Fields("RegionID"): 9997
Response.Write rsRegions.Fields("Description"): Region1

The Response.Write values are always same except for Response.Write
rsJsSelect.Fields("RegionID") which will give me exception error if I to
add:

" and NOT rsJsSelect.EOF" and "rsJsSelect.MoveNext"

without:

If (rsJsSelect.CursorType > 0) Then
  rsJsSelect.MoveFirst
 Else
  rsJsSelect.Requery
 End If

Thanks
George L.


Quote:
> Are you debugging your code?? Put in response.write statements to see
what's
> going on, or preferably use runtime debugging in Visual Interdev

> Jeff



> > I am using multiselect listbox in asp created by HTML <select name=""
> > size="" multiple> </select> tag...

> > Actually I think I am getting close, now I can display all required
> options
> > selected but in the same time those are only options that visible in
> > listbox. Where did rest of them go??? I suppose it has something to do
> with
> > positioning "NOT rsJsSelect.EOF" and "rsJsSelect.MoveNext" which I added
> to
> > the code, but can't seems to find right combination...
> > Any suggestions?
> > George L.

> > <select name="Regions" size="5" multiple>
> > <%
> >  While NOT rsRegions.EOF  and NOT rsJsSelect.EOF
> >   If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID")  Then
> >  %>
> > <option selected

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> > %></option>
> > <%
> >    Else
> > %>
> > <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> > %></option>
> > <%
> >  End If

> >  rsRegions.MoveNext
> > Wend
> >  If (rsRegions.CursorType > 0) Then
> >   rsRegions.MoveFirst
> >  Else
> >   rsRegions.Requery
> >  End If
> > %>
> > </select>



> > > Well George, let's see if we are talking about the same things:
> > > You are using a standard listbox control, right ?

> > > --
> > > Saludos, Jorge Jimenez, SICAD S.A., Costa Rica



> > > > Thanks, but ??? what do you mean? Forgive me I am really new at
this.

> > > > > 1. Activate the multiple selection property for the list

> > > > but it is activated:  <select name="Regions" size="5" multiple>

> > > > > 2. When adding the items to the list box, set the tag of each item
> > equal
> > > > to
> > > > > the recordsets bookmark

> > > > I am not adding anything, I am populating it from record set:
> > > >  <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> > > > %></option>

> > > > and finally:
> > > > > 3. When the user is finished selecting, just go through the list
> > > checking
> > > > > which items have the selected property set true and set the
> recordset
> > > > > bookmark equal to the items tag value.

> > > > I am not even getting to the point where user can select anything. I
> am
> > > > looking for a way how to PRESENT user with a listbox where one OR
> > multiple
> > > > values will be selected on page load according what user selected
> > > previously
> > > > in time (user's info from db). I don't know which values are those
or
> > how
> > > > many of them, can be one or hundreds of them...Everything suppose to
> be
> > > > dynamic.

> > > > Please, if you suggest anything, please be kind provide some code
> > example,
> > > > like I said: me=newbie :)
> > > > George L.



> > > > > If you want to use the listbox then :
> > > > > 1. Activate the multiple selection property for the list
> > > > > 2. When adding the items to the list box, set the tag of each item
> > equal
> > > > to
> > > > > the recordsets bookmark
> > > > > 3. When the user is finished selecting, just go through the list
> > > checking
> > > > > which items have the selected property set true and set the
> recordset
> > > > > bookmark equal to the items tag value.

> > > > > --
> > > > > Saludos, Jorge Jimenez, SICAD S.A., Costa Rica



> > > > > > Well, I still need help with this issue now for <select
multiple>
> > list
> > > > > box.
> > > > > > I can't really use AbsolutePosition, cause I never know how many
> > > records
> > > > > for
> > > > > > each user there will be.
> > > > > > So here is my question: How can I populate a listbox from one
> table
> > > AND
> > > > > keep
> > > > > > multiple values selected  according user's information from
> another
> > > > table?
> > > > > > My code so far will  select only one field which is match for
> first
> > > > record
> > > > > > in rsJsSelect.Fields("RegionID"). I know that I suppose to
somehow

> > > > > > <Get the value you want to select first. Compare this value to
the
> > > value
> > > > > of
> > > > > > <each option and add the "selected" attribute to the option if
> they
> > > are
> > > > > > equal...

> > > > > > But I can not really find any examples how to do this and I
don't
> > know
> > > > yet
> > > > > > how to do it by myself... Please help.

> > > > > > Thanks a lot in advance.
> > > > > > George L.

> > > > > > <%
> > > > > > set rsRegions = Server.CreateObject("ADODB.Recordset")
> > > > > > rsRegions.ActiveConnection = MYDBOCONNECTION
> > > > > > rsRegions.Source = "SELECT RegionID, Description FROM Regions
> ORDER
> > BY
> > > > > CASE
> > > > > > WHEN RegionID < 9000  THEN 2 ELSE 1 END, RegionID"
> > > > > > rsRegions.CursorType = 0
> > > > > > rsRegions.CursorLocation = 2
> > > > > > rsRegions.LockType = 3
> > > > > > rsRegions.Open()
> > > > > > rsRegions_numRows = 0
> > > > > > %>
> > > > > > <%
> > > > > > set rsJsSelect = Server.CreateObject("ADODB.Recordset")
> > > > > > rsJsSelect.ActiveConnection = MYDBOCONNECTION
> > > > > > rsJsSelect.Source = "SELECT RegionsCandidates.CandidateID,
> > > > > > RegionsCandidates.RegionID FROM RegionsCandidates WHERE
> > > > > > RegionsCandidates.CandidateID=280"
> > > > > > rsJsSelect.CursorType = 0
> > > > > > rsJsSelect.CursorLocation = 2
> > > > > > rsJsSelect.LockType = 3
> > > > > > rsJsSelect.Open()
> > > > > > rsJsSelect_numRows = 0
> > > > > > %>

> > > > > > <html>
> > > > > > <body>
> > > > > > <form>
> > > > > > <select name="Regions" size="5" multiple>
> > > > > > <%
> > > > > > While NOT rsRegions.EOF
> > > > > >     If rsRegions.Fields("RegionID")=

rsJsSelect.Fields("RegionID")
Quote:
> > > Then
> > > > > %>

> > > > > > <option selected

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> > > > > > %></option>

> > > > > > <%
> > > > > >  Else
> > > > > > %>
> > > > > > <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> > > > > > %></option>
> > > > > > <%
> > > > > >   End If
> > > > > >  rsRegions.MoveNext
> > > > > >  Wend
> > > > > >  If (rsRegions.CursorType > 0) Then
> > > > > >   rsRegions.MoveFirst
> > > > > >  Else
> > > > > >   rsRegions.Requery
> > > > > >  End If
> > > > > > %>
> > > > > > </select>
> > > > > > </form>
> > > > > > </body>
> > > > > > </html>



Sat, 11 Sep 2004 08:03:33 GMT  
 How to extract multiple records (rows) from one recordset -- now for listbox
With help of my friend, here is code which seems to work. Note change in
setting one of the cursors type to static, anything else and error will
result:

<%
set rsRegions = Server.CreateObject("ADODB.Recordset")
rsRegions.ActiveConnection = MYDBOCONNECTION
rsRegions.Source = "SELECT RegionID, Description FROM Regions ORDER BY CASE
WHEN RegionID < 9000  THEN 2 ELSE 1 END, RegionID"
rsRegions.CursorType = 0
rsRegions.CursorLocation = 2
rsRegions.LockType = 3
rsRegions.Open()
rsRegions_numRows = 0
%>
<%
set rsJsSelect = Server.CreateObject("ADODB.Recordset")
rsJsSelect.ActiveConnection = MYDBOCONNECTION
rsJsSelect.Source = "SELECT RegionsCandidates.CandidateID,
RegionsCandidates.RegionID FROM RegionsCandidates WHERE
RegionsCandidates.CandidateID=280"
rsJsSelect.CursorType = adOpenStatic
rsJsSelect.Open()
rsJsSelect_numRows = 0
%>

<html>
<body>
<form>
<select name="Regions" size="5" multiple>
<%
rsRegions.MoveFirst
  Do While NOT rsRegions.EOF
  rsJsSelect.MoveFirst
   rsJsSelect.Find "RegionID =" & rsRegions.Fields("RegionID")
  If Not rsJsSelect.EOF Then
%>
 <option selected
value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
%></option>
<%
  Else
%>
 <option
value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
%></option>
<%
  End If
  rsRegions.MoveNext
  Loop
 %>
</select>
</form>
</body>
</html>
<%
rsJsSelect.Close()
Set rsJsSelect=Nothing
%>
<%
rsRegions.Close()
Set rsRegions=Nothing
%>

Thanks all.
George L.


Quote:
> Well, I still need help with this issue now for <select multiple> list
box.
> I can't really use AbsolutePosition, cause I never know how many records
for
> each user there will be.
> So here is my question: How can I populate a listbox from one table AND
keep
> multiple values selected  according user's information from another table?
> My code so far will  select only one field which is match for first record
> in rsJsSelect.Fields("RegionID"). I know that I suppose to somehow

> <Get the value you want to select first. Compare this value to the value
of
> <each option and add the "selected" attribute to the option if they are
> equal...

> But I can not really find any examples how to do this and I don't know yet
> how to do it by myself... Please help.

> Thanks a lot in advance.
> George L.

> <%
> set rsRegions = Server.CreateObject("ADODB.Recordset")
> rsRegions.ActiveConnection = MYDBOCONNECTION
> rsRegions.Source = "SELECT RegionID, Description FROM Regions ORDER BY
CASE
> WHEN RegionID < 9000  THEN 2 ELSE 1 END, RegionID"
> rsRegions.CursorType = 0
> rsRegions.CursorLocation = 2
> rsRegions.LockType = 3
> rsRegions.Open()
> rsRegions_numRows = 0
> %>
> <%
> set rsJsSelect = Server.CreateObject("ADODB.Recordset")
> rsJsSelect.ActiveConnection = MYDBOCONNECTION
> rsJsSelect.Source = "SELECT RegionsCandidates.CandidateID,
> RegionsCandidates.RegionID FROM RegionsCandidates WHERE
> RegionsCandidates.CandidateID=280"
> rsJsSelect.CursorType = 0
> rsJsSelect.CursorLocation = 2
> rsJsSelect.LockType = 3
> rsJsSelect.Open()
> rsJsSelect_numRows = 0
> %>

> <html>
> <body>
> <form>
> <select name="Regions" size="5" multiple>
> <%
> While NOT rsRegions.EOF
>     If rsRegions.Fields("RegionID")= rsJsSelect.Fields("RegionID") Then
%>

> <option selected

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")
Quote:
> %></option>

> <%
>  Else
> %>
> <option

value="<%=rsRegions.Fields("RegionID")%>"><%=rsRegions.Fields("Description")

- Show quoted text -

Quote:
> %></option>
> <%
>   End If
>  rsRegions.MoveNext
>  Wend
>  If (rsRegions.CursorType > 0) Then
>   rsRegions.MoveFirst
>  Else
>   rsRegions.Requery
>  End If
> %>
> </select>
> </form>
> </body>
> </html>



Sun, 12 Sep 2004 03:07:25 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Module-level multiple-record recordset vs temp single-record recordset

2. Module-level multiple-record recordset vs temp single-record recordset

3. listbox with right alignment in a row ( one or 2 of seven rows)

4. How to display one record on one line in a listbox

5. Combine multiple recordsets into one recordset.

6. Load combo boxes: one recordset or multiple recordsets?

7. Display one record from multiple records

8. Finding Records and Updating Records in More than one Recordsets

9. How to display multiple fields on a row in listbox

10. Trouble concatenating multiple rows from one field

11. Populate Listbox, DBlist or Datalist control with several columns in one row with ado

12. Extracting records in a hierarchical recordset?

 

 
Powered by phpBB® Forum Software