Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Value in Drop Down List 2

Status
Not open for further replies.

DebbieC

Programmer
Mar 29, 2001
168
US
I have a form that has a drop down list that I am getting the values of from the database. It also runs a query when opening to list all entries in the database. Now I need to send the value of one of the items selected in the drop down to narrow down the list using a "Go" button. I had it working so that it passed the value and returned the right records but now it's not working. I also need it to keep the previously selected item from the drow down list.

This is what I have:

Set objConn = Server.CreateObject("adodb.Connection")
objConn.ConnectionString = CONN_STRING
objConn.CursorLocation = 3
objConn.Open

Set objRs = Server.CreateObject("adodb.Command")
objRs.ActiveConnection = objConn
objRs.CommandType = &H0004
objRs.CommandText = "stoSelectJurisdiction"

Set objRs = objRs.Execute




Set objConn2 = Server.CreateObject("adodb.Connection")
objConn2.ConnectionString = CONN_STRING
objConn2.CursorLocation = 3
objConn2.Open

Set objRs2 = Server.CreateObject("adodb.Command")
objRs2.ActiveConnection = objConn
objRs2.CommandType = &H0004
objRs2.CommandText = "stoSelectJurAccount"

objRs2.Parameters.Append _
objRs2.CreateParameter("JurID", adInteger, adParamInput, 4, JurID)

Set objRs2 = objRs2.Execute ' Execute stored procedure

<form method="post" action="JurAcct.asp?JurID=<%= JurID %>" name="frmServiceRequest">


<Select Name="JurID">
<option value="All" selected> All</option>

<% do while not objRs.EOF

If objRs("Organization") <> "" Then

If objRs("JurID") = Session("select" & JurID) Then
%>

<option value="<%= objRs("JurID") %>" selected><%= objRs("Organization") %>
</option>

<%
Else
%>

<option value="<%= objRs("JurID") %>"><%= objRs("Organization") %>

</option>

<%
End If

Else
End If

objRs.movenext()
loop
response.write "</select>"

%>

</select>&nbsp;&nbsp;

<input type=submit value="Go" id="btnGo" name="submit"></td>

<input type="hidden" name="JurID" value="<%= JurID %>">


Any suggestions?


 
this should do the trick

Code:
<!--#include file="../lib_func.asp"-->

<%

Dim JurID
[red]
If Request("JurID") = "" then
Jurid=""
else
Jurid=clng(Request("JurID"))
end if
[/red]

Set objConn = Server.CreateObject("adodb.Connection")
objConn.ConnectionString = CONN_STRING
objConn.CursorLocation = 3	' adUseClient
objConn.Open 


Set objRs = Server.CreateObject("adodb.Command")
objRs.ActiveConnection = objConn
objRs.CommandType = &H0004		' adCmdStoredProc
objRs.CommandText = "stoSelectJurisdiction"

Set objRs = objRs.Execute 


Set objRs2 = Server.CreateObject("adodb.Command")
objRs2.ActiveConnection = objConn
objRs2.CommandType = &H0004		' adCmdStoredProc
objRs2.CommandText = "stoSelectJurAccount"

objRs2.Parameters.Append _

objRs2.CreateParameter("JurID", adInteger, adParamInput, 4, JurID)	

Set objRs2 = objRs2.Execute ' Execute stored procedure


Dim strBgColor
Dim strColor1
Dim strColor2

strColor1="#FFFFFF"
strColor2="#F0F0F0"
strBgColor=strColor1
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<title>WRIB Website Administration</title>
<meta name="Description" content="San Bernardino County Fire Department">
<meta name="Keywords" content="sbcfire, San Bernardino County Fire Department, SB County Fire, County Fire, fire,hazmat, office of emergency services,oes">
<STYLE TYPE="text/css">
a.tree:link { color: 990100; text-decoration: none }
a.tree:active { color: 990100; text-decoration: none }
a.tree:visited { color: 990100; text-decoration: none }
a.tree:hover { color: 333366; text-decoration: underline; background: #FFF6C5 }
        </STYLE> 

    

        

	</head>

	<body background="../../images/background_wo_logo.jpg" bgcolor="#ffffff" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0" bgproperties="fixed">



		<a name="top"></a>

		<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0>

			<TR>

				<TD bgcolor="#333366">&nbsp;</TD>

			</TR>

		</TABLE>

   <table border="0" width="100%" cellpadding="8" cellspacing="5" style="border-collapse: collapse" bordercolor="#111111">

        <tr>

          <td width="100%" align="center">

            <img border="0" src="../../images/wrib_words.gif"><b><font face="Verdana" size="4" color="#C0C0C0"><br>

            <br>

            Jurisdiction

            Request Log</font></b><p><b>

            <font face="Verdana" size="4" color="#C0C0C0"></td>

			</tr>

        <tr>

          <td width="100%" align="center">


[red]
<form method="post" action="JurAcct.asp" name="frmServiceRequest">[/red]
            <table border="2" cellpadding="3" cellspacing="0" style="border-collapse: collapse" width="646" bordercolorlight="#C0C0C0" bordercolordark="#E6E6E6">

              <tr>

                <td width="96" bgcolor="#F0F0F0"><font face="Arial" size="2"><b>

                &nbsp;

                Jurisdiction:</b></font></td>

                               

                <td width="519">

                

                	<Select Name="JurID">
							<option value="" > All</option>
						<%	
							do while not objRs.EOF
								If objRs("Organization") <> "" Then
								
									[red]If JurID = clng(objRs("JurID")) Then[/red]
						%>			
									<option value="<%= objRs("JurID") %>" selected><%= objRs("Organization") %></option>
						<%	
									Else
						%>
									<option value="<%= objRs("JurID") %>"><%= objRs("Organization") %></option>						
						<%

									End If
								End If
					    	objRs.movenext()
					    	loop
						%> 
						</select>&nbsp;&nbsp;
						
                <input type=submit value="Go" id="btnGo" name="submit"></td>          
              </tr>

            </table>
            <p>

            <table border="2" cellpadding="3" cellspacing="0" style="border-collapse: collapse" id="AutoNumber1" width="752" bordercolorlight="#C0C0C0" bordercolordark="#E6E6E6">

              <tr>
                <td width="82" align="center" bgcolor="#F0F0F0"><b>
                <font face="Arial" size="2">Submit Date</font></b></td>
                <td width="78" align="center" bgcolor="#F0F0F0"><b>
                <font face="Arial" size="2">Status</font></b></td>
                <td width="77" align="center" bgcolor="#F0F0F0"><b>
                <font face="Arial" size="2">Status Date</font></b></td>
                <td width="72" align="center" bgcolor="#F0F0F0"><b>
                <font face="Arial" size="2">Test ID</font></b></td>
                <td width="150" align="center" bgcolor="#F0F0F0"><b>
                <font face="Arial" size="2">Form</font></b></td>
                <td width="105" align="center" bgcolor="#F0F0F0"><b>
                <font face="Arial" size="2">Exam</font></b></td>
                <td width="288" align="center" bgcolor="#F0F0F0"><b>
                <font face="Arial" size="2">Title</font></b></td>
              </tr>

              <% do while not objRs2.EOF %>
				<%         
				sType = objRs2("ReqType")
				Select Case sType
					Case "Draft"
						sFormDetail = "ReviewFormDetail.asp"
						sForm = "Review Draft"
					Case "Master"
						sFormDetail = "MasterFormDetail.asp"
						sForm = "Booklet Master"
					Case "Scoring"
						sFormDetail = "ScoringChecklistDetails.asp"
						sForm = "Scoring Process"
					Case "Feedback"
						sFormDetail = "FeedbackFormDetail.asp"
						sForm = "Feedback Form"
				End Select
				%>

              <tr bgColor=<%= strBgColor %>>

                <td width="82"><font face="Arial" size="2">&nbsp;<%= objRs2("DateReceived") %>&nbsp;</font></td>

                <td width="78"><font face="Arial" size="2">&nbsp;<%= objRs2("Status") %>&nbsp;</td>

                <td width="77"><font face="Arial" size="2">&nbsp;<%= objRs2("StatusDate") %>&nbsp;</td>

                <td width="72"><font face="Arial" size="2">&nbsp;<%= objRs2("TestID") %></font></td>

                <td width="150"><font face="Arial" size="2">&nbsp;<a href="<%= sFormDetail %>?request_id=<%= objRs2("RequestID") %>"><%= sForm %></a></font>&nbsp;</td>

                <td width="105"><font face="Arial" size="2">&nbsp;<a href="d:\inetpub\iuploads\hr\wrib\tests\<%= objRs2("ExamFile") %>"><%= objRs2("ExamFile") %></a></td>

                <td width="288"><font face="Arial" size="2">&nbsp;<%= objRs2("Title") %></font></td>

              </tr>

              <%
  					'Alternate row colors
					If strBgColor=strColor1 Then
						strBgColor=strColor2
					Else
						strBgColor=strColor1
					End If     
              objRs2.movenext()

			  loop
 			'Close connection

			objConn.Close

			Set objConn = nothing

				%>
            </table>
</form>
				</td>
			</tr>
		</table>
	</body>
[red]</html>[/red]

i've marked in red where changes occurred (that remember)
 
Thank you so much steven290. I really appreciate all of your help!!!!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top