T
Tom
Hello
In this sample code there is a drop down box that is populated with values
from the database. What is the right method to capture this user selected
value and to use that value as the filter for another drop down box or even
as a value to be processed by by the page?
Thanks
Tom
<%
'************************************
'Subroutine for droplist box
'
'PURPOSE: code to be called for placement of droplist box in a form or page
'
'PARAMETERS:
'strSQL = Defines SQL statement
'strFieldName = Defines field name in database table
'strDefault = Defines default value in droplist
'StrBoxName = Defines name of droplistbox
'strBoxTitle = Defines the title shown next to droplist box on screen
'strConn = Defines the database connection string
'*************************************
Sub Droplist(strSQL,strFieldName,strDefault,StrBoxName,strBoxTitle,strConn)
'Set Cursor
'-------------------------------------------------------------------------
Const adOpenStatic=3
' create the recordset, open it, and move to first record
'-------------------------------------------------------------------------
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open strSQL, strConn,adOpenStatic
rs.movefirst
'Ouput result to droplist box
'-------------------------------------------------------------------------
strBoxTitle%>
<SELECT Name = <%=StrBoxName%> SIZE="1">
<OPTION SELECTED> <%=strDefault%> </OPTION>
<%do until rs.EOF%>
<OPTION> <%=rs(strFieldName)%> </OPTION>
<%rs.movenext
loop%>
</Select>
<%
'Close and clean up
'-------------------------------------------------------------------------
rs.close
set rs=nothing
End sub
%>
////////////////////
HTML section
////////////////////
strSQL = "SELECT orders.[orderid] FROM orders ORDER BY orders.[orderid] "
strFieldName = "orderid"
strDefault = "default value"
StrBoxName = "name"
strBoxTitle = "<B>title: </B>"
strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; pwd=; DBQ="&
Server.MapPath("northwind.mdb")
Response.write ("Droplist box No.2" & "<BR>")
Call Droplist(strSQL,strFieldName,strDefault,StrBoxName,strBoxTitle,strConn)
In this sample code there is a drop down box that is populated with values
from the database. What is the right method to capture this user selected
value and to use that value as the filter for another drop down box or even
as a value to be processed by by the page?
Thanks
Tom
<%
'************************************
'Subroutine for droplist box
'
'PURPOSE: code to be called for placement of droplist box in a form or page
'
'PARAMETERS:
'strSQL = Defines SQL statement
'strFieldName = Defines field name in database table
'strDefault = Defines default value in droplist
'StrBoxName = Defines name of droplistbox
'strBoxTitle = Defines the title shown next to droplist box on screen
'strConn = Defines the database connection string
'*************************************
Sub Droplist(strSQL,strFieldName,strDefault,StrBoxName,strBoxTitle,strConn)
'Set Cursor
'-------------------------------------------------------------------------
Const adOpenStatic=3
' create the recordset, open it, and move to first record
'-------------------------------------------------------------------------
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open strSQL, strConn,adOpenStatic
rs.movefirst
'Ouput result to droplist box
'-------------------------------------------------------------------------
strBoxTitle%>
<SELECT Name = <%=StrBoxName%> SIZE="1">
<OPTION SELECTED> <%=strDefault%> </OPTION>
<%do until rs.EOF%>
<OPTION> <%=rs(strFieldName)%> </OPTION>
<%rs.movenext
loop%>
</Select>
<%
'Close and clean up
'-------------------------------------------------------------------------
rs.close
set rs=nothing
End sub
%>
////////////////////
HTML section
////////////////////
strSQL = "SELECT orders.[orderid] FROM orders ORDER BY orders.[orderid] "
strFieldName = "orderid"
strDefault = "default value"
StrBoxName = "name"
strBoxTitle = "<B>title: </B>"
strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; pwd=; DBQ="&
Server.MapPath("northwind.mdb")
Response.write ("Droplist box No.2" & "<BR>")
Call Droplist(strSQL,strFieldName,strDefault,StrBoxName,strBoxTitle,strConn)