fuxmyl
10-08-2004, 12:47 PM
I'm using this code to populate a dropdown list and it is working fine except I can't tell what value the selection has because when you make a selection it does nothing. I want to include this page inside a form that posts to itself (<!-- #include FILE="dropdown_ex.asp" -->) and use the value from the populated list. Is this possible or is there a better way? Here is the code for the dropdown list:
<!-- #include FILE="adovbs.inc" -->
<%
Set oConn = Server.CreateObject("ADODB.Connection")
Set oRs = Server.CreateObject("ADODB.Recordset")
oConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\mypath\parts.mdb"
strSQL = "SELECT * "
strSQL = strSQL & "FROM ppc where componet = 'Cabinet Configuration'"
oRs.Open strSQL, oConn, adOpenKeyset, adLockOptimistic
WHILE NOT oRs.EOF
' Change the 2 to a 1 to change the default option selected
IF oRs("ID") = 1 THEN
strPriority_type = strPriority_type & "<option selected value=" & oRs("compcode") & ">" & oRs("compdescription") & "</option>"
ELSE
strPriority_type = strPriority_type & "<option value=" & oRs("compcode") & ">" & oRs("compdescription") & "</option>"
END IF
oRs.MoveNext
WEND
oRs.Close
oConn.Close
%>
<html>
<head><title>Dynamic Drop-Down Menu Example</title></head>
<body>
<form method="POST" action="dropdown_ex.asp">
<p><select size="1" name="dropdown_menu">
<%=strPriority_type%>
</select></p>
</form>
</body>
</html>
Here is the page I'm trying to include the dropdown menu into:
<html><head>
<title>FormSubmitSelf.asp</title>
</head><body bgcolor="#FFFFFF">
<%
SELECT CASE lcase(request.form("configure"))
CASE "configure"
response.write "Your Part Number is "
response.write request.form("dropdown_menu")
response.write request.form("gr")
CASE ELSE
%>
<Form method="post">
Select Components:
<TABLE BORDER="1" WIDTH="100%">
<TR>
<TD WIDTH="50%">cabinet options:</TD>
<TD WIDTH="50%"><!-- #include FILE="dropdown_ex.asp" -->
</td>
</TR>
<TR>
<TD WIDTH="50%">Generator Receptacle:</TD>
<TD WIDTH="50%"><SELECT SIZE="1" NAME="gr">
<OPTION VALUE="S">standard</OPTION>
<OPTION VALUE="A">45 angle</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD WIDTH="50%"> </TD>
<TD WIDTH="50%"> </TD>
</TR>
<TR>
<TD WIDTH="50%"> </TD>
<TD WIDTH="50%"> </TD>
</TR>
</TABLE>
<p>
<br>
<input type="submit" name="Configure" value="Configure">
</form>
<%END SELECT%>
</body></html>
Can this work, or is there a better way?
<!-- #include FILE="adovbs.inc" -->
<%
Set oConn = Server.CreateObject("ADODB.Connection")
Set oRs = Server.CreateObject("ADODB.Recordset")
oConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\mypath\parts.mdb"
strSQL = "SELECT * "
strSQL = strSQL & "FROM ppc where componet = 'Cabinet Configuration'"
oRs.Open strSQL, oConn, adOpenKeyset, adLockOptimistic
WHILE NOT oRs.EOF
' Change the 2 to a 1 to change the default option selected
IF oRs("ID") = 1 THEN
strPriority_type = strPriority_type & "<option selected value=" & oRs("compcode") & ">" & oRs("compdescription") & "</option>"
ELSE
strPriority_type = strPriority_type & "<option value=" & oRs("compcode") & ">" & oRs("compdescription") & "</option>"
END IF
oRs.MoveNext
WEND
oRs.Close
oConn.Close
%>
<html>
<head><title>Dynamic Drop-Down Menu Example</title></head>
<body>
<form method="POST" action="dropdown_ex.asp">
<p><select size="1" name="dropdown_menu">
<%=strPriority_type%>
</select></p>
</form>
</body>
</html>
Here is the page I'm trying to include the dropdown menu into:
<html><head>
<title>FormSubmitSelf.asp</title>
</head><body bgcolor="#FFFFFF">
<%
SELECT CASE lcase(request.form("configure"))
CASE "configure"
response.write "Your Part Number is "
response.write request.form("dropdown_menu")
response.write request.form("gr")
CASE ELSE
%>
<Form method="post">
Select Components:
<TABLE BORDER="1" WIDTH="100%">
<TR>
<TD WIDTH="50%">cabinet options:</TD>
<TD WIDTH="50%"><!-- #include FILE="dropdown_ex.asp" -->
</td>
</TR>
<TR>
<TD WIDTH="50%">Generator Receptacle:</TD>
<TD WIDTH="50%"><SELECT SIZE="1" NAME="gr">
<OPTION VALUE="S">standard</OPTION>
<OPTION VALUE="A">45 angle</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD WIDTH="50%"> </TD>
<TD WIDTH="50%"> </TD>
</TR>
<TR>
<TD WIDTH="50%"> </TD>
<TD WIDTH="50%"> </TD>
</TR>
</TABLE>
<p>
<br>
<input type="submit" name="Configure" value="Configure">
</form>
<%END SELECT%>
</body></html>
Can this work, or is there a better way?