Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: ListBox with Multivalues and Databases. . How to ?


Message #1 by "Leo" <leo_sailer@h...> on Tue, 28 May 2002 22:58:26
Hi, 

Iīm new with ASP, I'd like to use a listbox such as a <SELECT> HTML Tag, 
but with several columns.
This listBox need to show information of a Database.
I know how to make a connection an retrieve the data but I coulnīt load in 
a ListBox.

Could someone send me a sample code ?

Thanks a lot
Message #2 by olgat@c... on Wed, 29 May 2002 09:00:25 +0200
Here a little example of code :
r - it's your recordset
<select name=3Dmylistbox >
do until r.EOF
	Response.Write "<option value=3D"&r.Fields("field")&">"
	r.MoveNext
loop

-----Original Message-----
From: Leo [mailto:leo_sailer@h...]
Sent: Wednesday, May 29, 2002 12:58 AM
To: ASP Web HowTo
Subject: [asp_web_howto] ListBox with Multivalues and Databases. . How
to ?


Hi,

I=B4m new with ASP, I'd like to use a listbox such as a <SELECT> HTML 
Tag,
but with several columns.
This listBox need to show information of a Database.
I know how to make a connection an retrieve the data but I couln=B4t 
load in
a ListBox.

Could someone send me a sample code ?

Thanks a lot

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogram
me
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogram
me
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogram
me
r-20
Message #3 by "Leo" <leo_sailer@h...> on Wed, 29 May 2002 14:48:45
Thanks for your help.
Perhaps I did explain me ok. My problem is that I have 4 columns with data 
and I would like to get the information of 3 of them using one as a 
reference, that is way I choose a listbox. I donīt know how I can put more 
than 2 columns neither how I can get the data inside the SELECT Tag, for 
example:

r - it's my recordset with these fields: name, phone, email and address.

<SELECT size=10 name=select1>
<%Do Until Tabla.EOF%>
<OPTION value=<%=r.Fields("Name")%>>
<%=r.Fields("phone")%>
</OPTION>
<% Tabla.MoveNext()
Loop %>
</SELECT>

And Getting data with select1.value

In this case I select by Name and I can Get the Phone, but I need the emal 
and Address too.

I will really appreciate if you can help me. Thanks in advance


> Here a little example of code :
r - it's your recordset
<select name=3Dmylistbox >
do until r.EOF
	Response.Write "<option value=3D"&r.Fields("field")&">"
	r.MoveNext
loop

-----Original Message-----
From: Leo [mailto:leo_sailer@h...]
Sent: Wednesday, May 29, 2002 12:58 AM
To: ASP Web HowTo
Subject: [asp_web_howto] ListBox with Multivalues and Databases. . How
to ?


Hi,

I=B4m new with ASP, I'd like to use a listbox such as a <SELECT> HTML 
Tag,
but with several columns.
This listBox need to show information of a Database.
I know how to make a connection an retrieve the data but I couln=B4t 
load in
a ListBox.

Could someone send me a sample code ?

Thanks a lot

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogram
me
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogram
me
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogram
me
r-20
Message #4 by olgat@c... on Wed, 29 May 2002 17:05:28 +0200
I would build an array with all data you need and fill your listbox 
from the
array and not from database.
option value=3Dindex from the array and then you can have all the 
needed data
from selected index in array
-----Original Message-----
From: Leo [mailto:leo_sailer@h...]
Sent: Wednesday, May 29, 2002 4:49 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: ListBox with Multivalues and Databases. .
How to ?


Thanks for your help.
Perhaps I did explain me ok. My problem is that I have 4 columns with 
data
and I would like to get the information of 3 of them using one as a
reference, that is way I choose a listbox. I don=B4t know how I can put 
more
than 2 columns neither how I can get the data inside the SELECT Tag, 
for
example:

r - it's my recordset with these fields: name, phone, email and 
address.

<SELECT size=3D10 name=3Dselect1>
<%Do Until Tabla.EOF%>
<OPTION value=3D<%=3Dr.Fields("Name")%>>
<%=3Dr.Fields("phone")%>
</OPTION>
<% Tabla.MoveNext()
Loop %>
</SELECT>

And Getting data with select1.value

In this case I select by Name and I can Get the Phone, but I need the 
emal
and Address too.

I will really appreciate if you can help me. Thanks in advance


> Here a little example of code :
r - it's your recordset=3D20
<select name=3D3Dmylistbox >
do until r.EOF
	Response.Write "<option value=3D3D"&r.Fields("field")&">"
	r.MoveNext
loop

-----Original Message-----
From: Leo [mailto:leo_sailer@h...]
Sent: Wednesday, May 29, 2002 12:58 AM
To: ASP Web HowTo
Subject: [asp_web_howto] ListBox with Multivalues and Databases. . How
to ?


Hi,=3D20

I=3DB4m new with ASP, I'd like to use a listbox such as a <SELECT> HTML 
=3D
Tag,=3D20
but with several columns.
This listBox need to show information of a Database.
I know how to make a connection an retrieve the data but I couln=3DB4t 
=3D
load in=3D20
a ListBox.

Could someone send me a sample code ?

Thanks a lot

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3D3Dnosim/theprogr
am=3D
me
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3D3Dnosim/theprogr
am=3D
me
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3D3Dnosim/theprogr
am=3D
me
r-20
---
Change your mail options at http://p2p.wrox.com/manager.asp or=3D20

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogram
me
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogram
me
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogram
me
r-20
Message #5 by "Leo" <leo_sailer@h...> on Thu, 30 May 2002 13:50:58
That is a great idea, Could you give another hand ?
This is the case, 
I am generate the array and make the <SELECT> using an index as OPTION 
Value, until now everything it is ok. I use a button to catch the index 
selected in the <SELECT>, but I canīt use the array variable, because it 
is outside the subrutine. Are any way to make reference to this array 
variable like Global variable or something like that ?

These is a part of the code:

<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--

Sub button1_onclick
Dim str, aux
str = Select1.value
aux = DbData(str,1) & DbData(str,2) & DbData(str,3)
msgbox(aux)
End Sub

-->
</SCRIPT>

 . . . . 

<SELECT size=10 name=select1 >
<%Do Until Tabla.EOF
  DbData(r,0) = Tabla.Fields("NodeName")
  DbData(r,1) = Tabla.Fields("NodeDesc")
  DbData(r,2) = Tabla.Fields("EaimName")
  DbData(r,3) = Tabla.Fields("EaimDesc")
  %>
<OPTION value=<%=r>>
<%= DbData(0)%>
</OPTION>
<% 
Tabla.MoveNext()
r = r +1
Loop %>
</SELECT>
<%cnn.Close
%><INPUT type="button" value="Button" id=button1 name=button1>





> I would build an array with all data you need and fill your listbox 
from the
array and not from database.
option value=3Dindex from the array and then you can have all the 
needed data
from selected index in array
-----Original Message-----
From: Leo [mailto:leo_sailer@h...]
Sent: Wednesday, May 29, 2002 4:49 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: ListBox with Multivalues and Databases. .
How to ?


Thanks for your help.
Perhaps I did explain me ok. My problem is that I have 4 columns with 
data
and I would like to get the information of 3 of them using one as a
reference, that is way I choose a listbox. I don=B4t know how I can put 
more
than 2 columns neither how I can get the data inside the SELECT Tag, 
for
example:

r - it's my recordset with these fields: name, phone, email and 
address.

<SELECT size=3D10 name=3Dselect1>
<%Do Until Tabla.EOF%>
<OPTION value=3D<%=3Dr.Fields("Name")%>>
<%=3Dr.Fields("phone")%>
</OPTION>
<% Tabla.MoveNext()
Loop %>
</SELECT>

And Getting data with select1.value

In this case I select by Name and I can Get the Phone, but I need the 
emal
and Address too.

I will really appreciate if you can help me. Thanks in advance


> Here a little example of code :
r - it's your recordset=3D20
<select name=3D3Dmylistbox >
do until r.EOF
	Response.Write "<option value=3D3D"&r.Fields("field")&">"
	r.MoveNext
loop

-----Original Message-----
From: Leo [mailto:leo_sailer@h...]
Sent: Wednesday, May 29, 2002 12:58 AM
To: ASP Web HowTo
Subject: [asp_web_howto] ListBox with Multivalues and Databases. . How
to ?


Hi,=3D20

I=3DB4m new with ASP, I'd like to use a listbox such as a <SELECT> HTML 
=3D
Tag,=3D20
but with several columns.
This listBox need to show information of a Database.
I know how to make a connection an retrieve the data but I couln=3DB4t 
=3D
load in=3D20
a ListBox.

Could someone send me a sample code ?

Thanks a lot

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3D3Dnosim/theprogr
am=3D
me
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3D3Dnosim/theprogr
am=3D
me
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3D3Dnosim/theprogr
am=3D
me
r-20
---
Change your mail options at http://p2p.wrox.com/manager.asp or=3D20

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogram
me
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogram
me
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogram
me
r-20
Message #6 by olgat@c... on Thu, 30 May 2002 17:23:33 +0200
Don't build your array in subroutine  (m I don't know VBScript, so I 
now if
you can do it without routine, but you can do it in JavaScript wothou
opening function

-----Original Message-----
From: Leo [mailto:leo_sailer@h...]
Sent: Thursday, May 30, 2002 3:51 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: ListBox with Multivalues and Databases. .
How to ?


That is a great idea, Could you give another hand ?
This is the case,
I am generate the array and make the <SELECT> using an index as OPTION
Value, until now everything it is ok. I use a button to catch the index 

selected in the <SELECT>, but I can=B4t use the array variable, because 
it
is outside the subrutine. Are any way to make reference to this array
variable like Global variable or something like that ?

These is a part of the code:

<SCRIPT ID=3DclientEventHandlersVBS LANGUAGE=3Dvbscript>
<!--

Sub button1_onclick
Dim str, aux
str =3D Select1.value
aux =3D DbData(str,1) & DbData(str,2) & DbData(str,3)
msgbox(aux)
End Sub

-->
</SCRIPT>

 . . . .

<SELECT size=3D10 name=3Dselect1 >
<%Do Until Tabla.EOF
  DbData(r,0) =3D Tabla.Fields("NodeName")
  DbData(r,1) =3D Tabla.Fields("NodeDesc")
  DbData(r,2) =3D Tabla.Fields("EaimName")
  DbData(r,3) =3D Tabla.Fields("EaimDesc")
  %>
<OPTION value=3D<%=3Dr>>
<%=3D DbData(0)%>
</OPTION>
<%
Tabla.MoveNext()
r =3D r +1
Loop %>
</SELECT>
<%cnn.Close
%><INPUT type=3D"button" value=3D"Button" id=3Dbutton1 name=3Dbutton1>





> I would build an array with all data you need and fill your listbox 
=3D
from the
array and not from database.
option value=3D3Dindex from the array and then you can have all the =3D
needed data
from selected index in array
-----Original Message-----
From: Leo [mailto:leo_sailer@h...]
Sent: Wednesday, May 29, 2002 4:49 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: ListBox with Multivalues and Databases. .
How to ?


Thanks for your help.
Perhaps I did explain me ok. My problem is that I have 4 columns with 
=3D
data=3D20
and I would like to get the information of 3 of them using one as 
a=3D20
reference, that is way I choose a listbox. I don=3DB4t know how I can 
put =3D
more=3D20
than 2 columns neither how I can get the data inside the SELECT Tag, 
=3D
for=3D20
example:

r - it's my recordset with these fields: name, phone, email and =3D
address.

<SELECT size=3D3D10 name=3D3Dselect1>
<%Do Until Tabla.EOF%>
<OPTION value=3D3D<%=3D3Dr.Fields("Name")%>>
<%=3D3Dr.Fields("phone")%>
</OPTION>
<% Tabla.MoveNext()
Loop %>
</SELECT>

And Getting data with select1.value

In this case I select by Name and I can Get the Phone, but I need the 
=3D
emal=3D20
and Address too.

I will really appreciate if you can help me. Thanks in advance


> Here a little example of code :
r - it's your recordset=3D3D20
<select name=3D3D3Dmylistbox >
do until r.EOF
	Response.Write "<option value=3D3D3D"&r.Fields("field")&">"
	r.MoveNext
loop

-----Original Message-----
From: Leo [mailto:leo_sailer@h...]
Sent: Wednesday, May 29, 2002 12:58 AM
To: ASP Web HowTo
Subject: [asp_web_howto] ListBox with Multivalues and Databases. . How
to ?


Hi,=3D3D20

I=3D3DB4m new with ASP, I'd like to use a listbox such as a <SELECT> 
HTML =3D
=3D3D
Tag,=3D3D20
but with several columns.
This listBox need to show information of a Database.
I know how to make a connection an retrieve the data but I 
couln=3D3DB4t =3D
=3D3D
load in=3D3D20
a ListBox.

Could someone send me a sample code ?

Thanks a lot

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3D3D3Dnosim/thepro
gr=3D
am=3D3D
me
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3D3D3Dnosim/thepro
gr=3D
am=3D3D
me
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3D3D3Dnosim/thepro
gr=3D
am=3D3D
me
r-20
---
Change your mail options at http://p2p.wrox.com/manager.asp or=3D3D20

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3D3Dnosim/theprogr
am=3D
me
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3D3Dnosim/theprogr
am=3D
me
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3D3Dnosim/theprogr
am=3D
me
r-20
---
Change your mail options at http://p2p.wrox.com/manager.asp or=3D20

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogram
me
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogram
me
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogram
me
r-20

  Return to Index