web 2.0

How to used ASP & ListMenu/DropDownList From Database

How to used ASP & ListMenu/DropDownList From Database This the tutorial/example a scripts how to use ASP & ListMenu/DropDownList From Database

ShotDev Focus:
- ASP & ListMenu/DropDownList From Database

Example

asp_listmenu_datebase1.asp


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<%
Dim Conn,strSQL,objRec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("db/mydatabase.mdb"),"" , ""
%>
<body>
<form action="asp_listmenu_datebase2.asp" method="post" name="form1">
List Menu<br>
<select name="lmName1">
<option value=""><-- Please Select Item --></option>
<%
strSQL = "SELECT * FROM customer "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
While Not objRec.EOF
%>
<option value="<%=objRec.Fields("CustomerID").Value%>"><%=objRec.Fields("CustomerID").Value & " - " & objRec.Fields("Name").Value%></option>
<%
objRec.MoveNext
Wend
%>
</select>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>

asp_listmenu_datebase2.asp


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<%
Dim Conn,strSQL,objRec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("db/mydatabase.mdb"),"" , ""
%>
<body>
<%
Response.write Request.Form("lmName1")

Response.write "<hr>"

strSQL = "SELECT * FROM customer WHERE CustomerID = '"&Request.Form("lmName1")&"'  "
Set objRec = Conn.Execute(strSQL)

Response.write objRec.Fields("Name").Value
%>
</body>
</html>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>

asp_listmenu_datebase3.asp


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<%
Dim Conn,strSQL,objRec,strDefault,strSel
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("db/mydatabase.mdb"),"" , ""

strDefault = "C003"
%>
<body>
<form action="php_listmenu_datebase2.php" method="post" name="form1">
List Menu<br>
<select name="lmName1">
<option value=""><-- Please Select Item --></option>
<%
strSQL = "SELECT * FROM customer "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
While Not objRec.EOF
If strDefault = objRec.Fields("CustomerID").Value Then
strSel = "selected"
Else
strSel = ""
End IF
%>
<option value="<%=objRec.Fields("CustomerID").Value%>" <%=strSel%>><%=objRec.Fields("CustomerID").Value & " - " & objRec.Fields("Name").Value%></option>
<%
objRec.MoveNext
Wend
%>
</select>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_listmenu_datebase1.asp

Screenshot

ASP & ListMenu/DropDownList From Database

ASP & ListMenu/DropDownList From Database

ASP & ListMenu/DropDownList From Database
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.