Dropdown der opdaterer sig selv
jeg har 2 dropdown hvor indholdet i den ene er afhængigt af valget i den anden. http://www.capitolshop.dk/new_product_search.aspmen jeg har 2 problemer:
1. når brugeren har valgt mærke ændrer kategori sig efter hans valg. MEN jeg vil gerne have at det valgte mærke bliver stående i Mærke dropdown.
2. det skal være muligt at vælge kategori uden at vælge mærke.
koden kommer her:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/capitol.asp" -->
<%
Dim rsBrand
Dim rsBrand_numRows
Set rsBrand = Server.CreateObject("ADODB.Recordset")
rsBrand.ActiveConnection = MM_capitol_STRING
rsBrand.Source = "SELECT DISTINCT Brand FROM Product ORDER BY Brand ASC"
rsBrand.CursorType = 0
rsBrand.CursorLocation = 2
rsBrand.LockType = 1
rsBrand.Open()
rsBrand_numRows = 0
%>
<%
Dim rsCategory__varBrand
rsCategory__varBrand = "1"
If (Request.Querystring("Brand") <> "") Then
rsCategory__varBrand = Request.Querystring("Brand")
End If
%>
<%
Dim rsCategory
Dim rsCategory_numRows
Set rsCategory = Server.CreateObject("ADODB.Recordset")
rsCategory.ActiveConnection = MM_capitol_STRING
rsCategory.Source = "SELECT DISTINCT Category FROM Product WHERE Brand = '" + Replace(rsCategory__varBrand, "'", "''") + "' ORDER BY Category ASC"
rsCategory.CursorType = 0
rsCategory.CursorLocation = 2
rsCategory.LockType = 1
rsCategory.Open()
rsCategory_numRows = 0
%>
<%
Dim rsBrandSelected__varBrand
rsBrandSelected__varBrand = "1"
If (Request.Querystring("Brand") <> "") Then
rsBrandSelected__varBrand = Request.Querystring("Brand")
End If
%>
<%
Dim rsBrandSelected
Dim rsBrandSelected_numRows
Set rsBrandSelected = Server.CreateObject("ADODB.Recordset")
rsBrandSelected.ActiveConnection = MM_capitol_STRING
rsBrandSelected.Source = "SELECT * FROM Product WHERE Brand = '" + Replace(rsBrandSelected__varBrand, "'", "''") + "' ORDER BY Brand ASC"
rsBrandSelected.CursorType = 0
rsBrandSelected.CursorLocation = 2
rsBrandSelected.LockType = 1
rsBrandSelected.Open()
rsBrandSelected_numRows = 0
%>
<script language="JavaScript">
function updatecategory(value) {
window.location = "new_product_search.asp?brand="+value;
}
</script>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="capitol.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="/dk_products.asp" method="post" name="productsearch" target="_top" id="productsearch">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="menuHead">Produktsøgning</td>
</tr>
<tr>
<td><select name="Brand" id="Brand" class="searchFields" onChange="updatecategory(value)">
<option value="">Vælg mærke</option>
<%
While (NOT rsBrand.EOF)
%>
<option value="<%=(rsBrand.Fields.Item("Brand").Value)%>"><%=(rsBrand.Fields.Item("Brand").Value)%></option>
<%
rsBrand.MoveNext()
Wend
If (rsBrand.CursorType > 0) Then
rsBrand.MoveFirst
Else
rsBrand.Requery
End If
%>
</select></td>
</tr>
<tr>
<td><select name="Category" id="Category" class="searchFields">
<option value="">Vælg kategori</option>
<%
While (NOT rsCategory.EOF)
%>
<option value="<%=(rsCategory.Fields.Item("Category").Value)%>"><%=(rsCategory.Fields.Item("Category").Value)%></option>
<%
rsCategory.MoveNext()
Wend
If (rsCategory.CursorType > 0) Then
rsCategory.MoveFirst
Else
rsCategory.Requery
End If
%>
</select></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
<%
rsBrand.Close()
Set rsBrand = Nothing
%>
<%
rsCategory.Close()
Set rsCategory = Nothing
%>
<%
rsBrandSelected.Close()
Set rsBrandSelected = Nothing
%>
jeg har desværre ikke mere end 21 point :(
