longmatch
Programmer
- Nov 1, 2001
- 406
Dear All:
I have designed a linked combobox, I would like to know how to add this into my current application. Right now I used a form to include the twp comboboxes, the form will be submitted when item in the first combo box is selected. In my current ASP page, there is form. The data will be sent to database after submitting. I would like to know how to integrate the two combo boxes into my current application.
Big thanks
Haijun
<!--#include file="ClssfdPage.asp"-->
<%
call main
sub main
' If the form is submitted, just display the selected Procedure and state
If Request.Form("cmdSubmit"
<> "" Then
Response.Write "<B> Category = " & Request.Form("lstCategory"
& _
" Procedure = " & Request.Form("lstProcedure"
exit sub
End If
Dim strSQL ' SQL query to be executed
Dim rsCategory ' recordset that holds the Category Information
Dim rsProcedure ' recordset that holds the Procedure Information
Dim strCategory ' holds the Category ID
Dim strProcedure ' holds the Procedure ID
Set rsCategory = Server.CreateObject("ADODB.Recordset"
Set rsProcedure = Server.CreateObject("ADODB.Recordset"
strSQL = "SELECT * FROM Category"
rsCategory.Open strSQL,objConn,adOpenKeyset,adLockOptimistic
' Check if theres a Category selected by the user
' If not, just take the first Category as the
' filter for the Procedure List
strCategory = Request.Form("lstCategory"
If strCategory = "" Then
If Not rsCategory.EOF Then
strCategory = rsCategory("Category"
End If
End If
If strCategory <> "" Then
strSQL= "SELECT * FROM Procedurelist2 WHERE categoryID = '" & strCategory & "'"
rsProcedure.Open strSQL,objConn,adOpenKeyset,adLockOptimistic
strProcedure = Request.Form("lstProcedure"
If strProcedure = "" Or Request.Form("hid_Category_Changed"
= "True" Then
If Not rsProcedure.EOF Then
strProcedure = rsProcedure("Procedure"
End If
End If
End If
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<CENTER>
<FORM NAME=frmHierarchy METHOD=post ACTION="combobox.asp">
<INPUT TYPE=HIDDEN NAME=hid_Category_Changed>
<INPUT TYPE=HIDDEN NAME=hid_Procedure_Changed>
<P><H2>Hierarchial Selection of Items</H2></P>
<TABLE CELLSPACING=5 CELLPADDING=5 BORDER=0 ALIGN="CENTER">
<TR>
<TD>Category: </TD>
<TD><SELECT id=lstCategory name=lstCategory onchange="ChangeCategory()">
<%
' Add the Categorys to the list
If Not rsCategory.EOF Then
Do While Not rsCategory.EOF
strCategory = rsCategory("category"
If rsCategory("category"
= Request.Form("lstCategory"
Then %>
<OPTION VALUE="<%=rsCategory("Category"
%>" SELECTED> <%=strCategory%></OPTION>
<%
Else
%>
<OPTION VALUE="<%=rsCategory("Category"
%>" > <%=strCategory%></OPTION>
<%
End If
rsCategory.MoveNext
Loop
End If
'Reset the record pointer to the first record
rsCategory.MoveFirst
%>
</SELECT></TD>
</TR>
<TR>
<TD>Procedure: </TD>
<TD><SELECT id=lstProcedure name=lstProcedure onchange="ChangeProcedure()" >
<%
' Add the countries to the list
If Not rsProcedure.EOF Then
Do While Not rsProcedure.EOF
strProcedure = rsProcedure("Procedure"
If rsProcedure("Procedure"
= Request.Form("lstProcedure"
Then
%>
<OPTION Value="<%=rsProcedure("Procedure"
%>" SELECTED> <%=strProcedure%></OPTION>
<%
Else
%>
<OPTION Value="<%=rsProcedure("Procedure"
%>" > <%=strProcedure%></OPTION>
<%
End If
rsProcedure.MoveNext
Loop
End If
'Reset the record pointer to the first record
rsProcedure.MoveFirst
%>
</SELECT></TD>
</TABLE>
<P><INPUT id=cmdSubmit name=cmdSubmit type=submit value=Submit></P>
</FORM>
</CENTER>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
function ChangeCategory()
{
document.frmHierarchy.hid_Category_Changed.value = "True";
document.frmHierarchy.submit();
}
function ChangeProcedure()
{
document.frmHierarchy.hid_Procedure_Changed.value = "True";
document.frmHierarchy.submit();
}
</SCRIPT>
</HTML>
<%
' Release the connection and recordsets
Set objConn = Nothing
Set rsProcedure = Nothing
end sub
%>
I have designed a linked combobox, I would like to know how to add this into my current application. Right now I used a form to include the twp comboboxes, the form will be submitted when item in the first combo box is selected. In my current ASP page, there is form. The data will be sent to database after submitting. I would like to know how to integrate the two combo boxes into my current application.
Big thanks
Haijun
<!--#include file="ClssfdPage.asp"-->
<%
call main
sub main
' If the form is submitted, just display the selected Procedure and state
If Request.Form("cmdSubmit"
Response.Write "<B> Category = " & Request.Form("lstCategory"
" Procedure = " & Request.Form("lstProcedure"
exit sub
End If
Dim strSQL ' SQL query to be executed
Dim rsCategory ' recordset that holds the Category Information
Dim rsProcedure ' recordset that holds the Procedure Information
Dim strCategory ' holds the Category ID
Dim strProcedure ' holds the Procedure ID
Set rsCategory = Server.CreateObject("ADODB.Recordset"
Set rsProcedure = Server.CreateObject("ADODB.Recordset"
strSQL = "SELECT * FROM Category"
rsCategory.Open strSQL,objConn,adOpenKeyset,adLockOptimistic
' Check if theres a Category selected by the user
' If not, just take the first Category as the
' filter for the Procedure List
strCategory = Request.Form("lstCategory"
If strCategory = "" Then
If Not rsCategory.EOF Then
strCategory = rsCategory("Category"
End If
End If
If strCategory <> "" Then
strSQL= "SELECT * FROM Procedurelist2 WHERE categoryID = '" & strCategory & "'"
rsProcedure.Open strSQL,objConn,adOpenKeyset,adLockOptimistic
strProcedure = Request.Form("lstProcedure"
If strProcedure = "" Or Request.Form("hid_Category_Changed"
If Not rsProcedure.EOF Then
strProcedure = rsProcedure("Procedure"
End If
End If
End If
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<CENTER>
<FORM NAME=frmHierarchy METHOD=post ACTION="combobox.asp">
<INPUT TYPE=HIDDEN NAME=hid_Category_Changed>
<INPUT TYPE=HIDDEN NAME=hid_Procedure_Changed>
<P><H2>Hierarchial Selection of Items</H2></P>
<TABLE CELLSPACING=5 CELLPADDING=5 BORDER=0 ALIGN="CENTER">
<TR>
<TD>Category: </TD>
<TD><SELECT id=lstCategory name=lstCategory onchange="ChangeCategory()">
<%
' Add the Categorys to the list
If Not rsCategory.EOF Then
Do While Not rsCategory.EOF
strCategory = rsCategory("category"
If rsCategory("category"
<OPTION VALUE="<%=rsCategory("Category"
<%
Else
%>
<OPTION VALUE="<%=rsCategory("Category"
<%
End If
rsCategory.MoveNext
Loop
End If
'Reset the record pointer to the first record
rsCategory.MoveFirst
%>
</SELECT></TD>
</TR>
<TR>
<TD>Procedure: </TD>
<TD><SELECT id=lstProcedure name=lstProcedure onchange="ChangeProcedure()" >
<%
' Add the countries to the list
If Not rsProcedure.EOF Then
Do While Not rsProcedure.EOF
strProcedure = rsProcedure("Procedure"
If rsProcedure("Procedure"
%>
<OPTION Value="<%=rsProcedure("Procedure"
<%
Else
%>
<OPTION Value="<%=rsProcedure("Procedure"
<%
End If
rsProcedure.MoveNext
Loop
End If
'Reset the record pointer to the first record
rsProcedure.MoveFirst
%>
</SELECT></TD>
</TABLE>
<P><INPUT id=cmdSubmit name=cmdSubmit type=submit value=Submit></P>
</FORM>
</CENTER>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
function ChangeCategory()
{
document.frmHierarchy.hid_Category_Changed.value = "True";
document.frmHierarchy.submit();
}
function ChangeProcedure()
{
document.frmHierarchy.hid_Procedure_Changed.value = "True";
document.frmHierarchy.submit();
}
</SCRIPT>
</HTML>
<%
' Release the connection and recordsets
Set objConn = Nothing
Set rsProcedure = Nothing
end sub
%>