Go4Expert

Go4Expert (http://www.go4expert.com/)
-   ASP (http://www.go4expert.com/forums/asp/)
-   -   Help with dropdownlist problem (http://www.go4expert.com/forums/help-dropdownlist-t4599/)

MastaKay 8Jun2007 16:23

Help with dropdownlist problem
 
Hi all.

I have managed to get this code that seems to do what I want but doesnt show the values.its builds a dropdownlist and loads values into it and show the prints the values on the page.the problem is that it doesnt show any errors and doesnt display the values either.

Someone please help.I need this figured out as soon as now.

Code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- METADATA TYPE="typelib"
              FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
Option Explicit

'-- Variables we are using
dim objConn, objRS, objRS2, strSQL

'-- Define our objects
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
Set objRS2 = Server.CreateObject("ADODB.Recordset")

'-- Database path and Data provider
objConn.ConnectionString = Server.MapPath("C:\dropdowns.mdb")
objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
objConn.Open

'-- Sub Procedure that builds the dropdown list
Sub showDropDownList(c, r, table)
       
        '-- SQL Statement
        strSQL = "SELECT * FROM " & tblDropDownTest & " ORDER BY Title ASC"
        '-- Execute our SQL statement and store the recordset
        Set r = c.Execute(strSQL)
       
        '-- If we have records to return
        if r.eof = false then
        '-- Open a form/select tag
        Response.Write "<form name=""form1"">"
        Response.Write "<select name=""dropdownlist"">" & vbCrLf
        Response.Write "<option selected=""selected"" value="""">Choose....</option>"
                '-- loop and build each database entry as a selectable option
                While r.EOF = false
                        Response.Write "<option value=""Index.html"">" _
                        & r.Fields("Title").Value & "</option>" & vbCrLf
                '-- Move recordset to the next value
                r.movenext
                Wend
                else
                response.write"<"Sorry, no records selected">"
        end if
        '-- close select/form tags
        Response.Write "</select></form>" & vbCrLf
       
End Sub

'-- Sub Procedure that builds the dropdown list
Sub showDropDownList2(c, r, table)
       
        '-- SQL Statement
        strSQL = "SELECT * FROM " & tblDropDownTest & " ORDER BY Title ASC"
        '-- Execute our SQL statement and store the recordset
        r.Open strSQL, c, 3, 3
       
        '-- If we have records to return
        if r.eof = false then
        '-- Open a form/select tag
        Response.Write "<form name=""form1"">"
        Response.Write "<select name=""dropdownlist"">" & vbCrLf
                '-- loop and build each database entry as a selectable option
                'filter
                r.Filter = ("Type = 'fruit'")
                Response.Write "<option selected=""selected"" value="""">Choose....</option>"
                Response.Write "<optgroup label=""Fruit""></optgroup>"
                While r.EOF = false
                        Response.Write "<option value=""Index.html"">" _
                        & r.Fields("Title").Value & "</option>" & vbCrLf
                '-- Move recordset to the next value
                r.movenext
                Wend
               
                r.Filter = adFilterNone
               
                r.Filter = ("Type = 'veg'")
                Response.Write "<optgroup label=""Veg""></optgroup>"
                While r.EOF = false
                        Response.Write "<option value=""Index.html"">" _
                        & r.Fields("Title").Value & "</option>" & vbCrLf
                '-- Move recordset to the next value
                r.movenext
                Wend
        end if
        '-- close select/form tags
        Response.Write "</select></form>" & vbCrLf
       
End Sub
%>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dynamic dropdown lists in ASP(VBScript) - designplace.org</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Dynamic dropdown lists using Active Server Pages and Microsoft Access" />
<meta name="Author" content="Matt Millross" />
</head>

<body>
<h1>Dynamic dropdown lists using Active Server Pages and Microsoft Access</h1>
<p>Below is an example of a drop down list, dynamically populated from a
database table.</p>

<p>
  <%
' -- Call the sub procedure to build the drop down list, with the connection and recordset objects and the source table (In quotes).
call showDropDownList(objConn, objRS, "tblDropDownTest")
Sub showDropDownList(c, r, table)
       
        '-- SQL Statement
        strSQL = "SELECT * FROM " & tblDropDownTest & " ORDER BY Title ASC"
        '-- Execute our SQL statement and store the recordset
        Set r = c.Execute(strSQL)
       
        '-- If we have records to return
        if r.eof = false then
        '-- Open a form/select tag
        Response.Write "<form name=""form1"">"
        Response.Write "<select name=""dropdownlist"">" & vbCrLf
        Response.Write "<option selected=""selected"" value="""">Choose....</option>"
                '-- loop and build each database entry as a selectable option
                While r.EOF = false
                        Response.Write "<option value=""Index.html"">" _
                        & r.Fields("Title").Value & "</option>" & vbCrLf
                '-- Move recordset to the next value
                r.movenext
                Wend
                else
                response.write"<"Sorry, no records selected">"
        end if
        '-- close select/form tags
        Response.Write "</select></form>" & vbCrLf
       
End Sub
%>
</p>
<p>Here is the same drop down list, but this time it has been filtered to show
fruit first under a heading, then veg.</p>
<p>
<%
' -- Call the sub procedure to build the drop down list, with the connection and recordset objects and the source table (In quotes).
call showDropDownList2(objConn, objRS2, "tblDropDownTest")
%>
</p>
<p> designplace.org - Feb 2003</p>

</body>
</html>


MastaKay 25Jun2007 11:53

Re: Help with dropdownlist problem
 
Thanks Im jus gona try it now and see if there are any changes.Thank you very much


All times are GMT +5.5. The time now is 18:00.