|
 |
asp_databases thread: drop down menu from table field
Message #1 by Arsal <arsal21@y...> on Sun, 22 Apr 2001 22:50:32 -0700 (PDT)
|
|
is it possible to display the contects of the column (of
some MS. Access Table) in a drop down menu box.
what's the code ?
Message #2 by "Pappas Nikos" <pappas@c...> on Mon, 23 Apr 2001 10:18:34 +0300
|
|
<%@ Language=VBScript %>
<!-- #include file="adovbs.inc" -->
<% 'Create the recordset
set conn=server.createobject("adodb.connection")
set rs = Server.CreateObject("ADODB.Recordset")
conn.open session("connection_string")
set rs = conn.execute("select * from tblEmployee")
'Now write the dropdown.
%>
<select name="Employee" size="1">
<%
do while not rs.eof %>
<%
response.write "<option value=" + Cstr(rs("EmpID")) +">" +
rs("EmployeeName")+ "</option>"
rs.movenext
loop
%></select>
-----Original Message-----
From: Arsal
Sent: Monday, April 23, 2001 8:51 AM
To: ASP Databases
Subject: [asp_databases] drop down menu from table field
is it possible to display the contects of the column (of
some MS. Access Table) in a drop down menu box.
what's the code ?
Message #3 by "Charles Feduke" <webmaster@r...> on Mon, 23 Apr 2001 20:24:57 -0400
|
|
Let's assume your dropdown table is called "tblState" and you have a valid
connection string in sConnection:
<%
Dim rsState, sSelectedState, sSel
sSelectedState = "VA" ' just an example
Set rsState = Server.CreateObject("ADODB.Recordset")
' get the data
rsState.ActiveConnection = sConnection
rsState.Open "SELECT state FROM tblState ORDER BY state", , adCmdText
%>
<SELECT NAME="state">
<%
Do Until rsState.EOF
If LCase(rsState("state")) = LCase(sSelectedState) Then sSel = "
SELECTED" Else sSel = ""
%>
<OPTION
VALUE="<%=rsState("state")%>"<%=sSEL%>><%=rsState("state")%></OPTION>
<%
' since the value is the same as the text, it is completely optional and
included
' only for completeness
rsState.MoveNext
Loop
%>
</SELECT>
<%
' clean up
rsState.Close
Set rsState = Nothing
%>
Hope that helps.
- Chuck
----- Original Message -----
From: "Arsal" <arsal21@y...>
To: "ASP Databases" <asp_databases@p...>
Sent: Monday, April 23, 2001 1:50 AM
Subject: [asp_databases] drop down menu from table field
> is it possible to display the contects of the column (of
> some MS. Access Table) in a drop down menu box.
> what's the code ?
|
|
 |