Dynamic Dropdown Lists Support Product Page

This topic was archived

dynamic jump menus

Asked 15 Oct 2004 22:00:46
1
has this question
15 Oct 2004 22:00:46 marie-Joelle Mayou posted:
I am new at programming ASP and cannot solve this problem. The user of my page should be able to select a country from the jump with values coming from a database, and a list of cities from the selected country will populate a list. Here are my code it does not work.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/cntphotos.asp" -->
<%
Dim rcCountry
Dim rcCountry_numRows

Set rcCountry = Server.CreateObject("ADODB.Recordset"
rcCountry.ActiveConnection = MM_cntphotos_STRING
rcCountry.Source = "SELECT distinct countryName FROM qrCountry_city"
rcCountry.CursorType = 0
rcCountry.CursorLocation = 2
rcCountry.LockType = 1
rcCountry.Open()

rcCountry_numRows = 0
%>
<%
Dim RcCity__MMColParam
RcCity__MMColParam = "1"
If (Request.QueryString("CountryName" <> "" Then
RcCity__MMColParam = Request.QueryString("CountryName"
End If
%>
<%
Dim RcCity
Dim RcCity_numRows

Set RcCity = Server.CreateObject("ADODB.Recordset"
RcCity.ActiveConnection = MM_cntphotos_STRING
RcCity.Source = "SELECT * FROM qrCountry_city WHERE CountryID = " + Replace(RcCity__MMColParam, "'", "''" + " ORDER BY CityName ASC"
RcCity.CursorType = 0
RcCity.CursorLocation = 2
RcCity.LockType = 1
RcCity.Open()

RcCity_numRows = 0
%>
<html xmlns="www.w3.org/1999/xhtml">
<head>
<title>Thatcher Photos Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="photos.css" />
<script language="JavaScript" type="text/JavaScript">
<!--

}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location=search.asp?countryname="+selObj.options[selObj.selectedIndex].value+"'";
if (restore) selObj.selectedIndex=0;
}



//-->
</script>
</head>

<body>
<table width="95%" border="1" cellpadding="3" cellspacing="0" align="center" >
<tr class="Table">
<td width="28%" class="rowtitle"><img src="images/lilies.jpg" width="200" height="150" />
</td>
<td width="50%" class="border" >

<p class="titletext">Welcome </p>
<p class="titletext">to </p>
<p class="titletext">Thatcher Photos Album</p>
</td>
<td width="22%" class="rowtitle" ><img src="images/lilies.jpg" width="200" height="150" class="titletext" /></td>
</tr>
<tr class="Table">
<td colspan="3" class="Search"><div align="center">Photos Search</div></td>
</tr>
<tr class="Table">
<td colspan="3">

<table width="100%" border="1" cellspacing="0" cellpadding="3" align="center" >
<tr class="SearchRow">
<td width="31%">Country:</td>
<td width="28%">City:</td>
<td width="41%">Location:</td>
</tr>
<tr>
<td colspan="2">
<form name="search" id="search">
<select name="mnCountry" onchange="MM_jumpMenu('parent',this,0)">
<option selected="selected" value="" <%If (Not isNull((RcCity.Fields.Item("CountryName".Value))) Then If ("" = CStr((RcCity.Fields.Item("CountryName".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Choose
One</option>
<%
While (NOT rcCountry.EOF)
%>
<option value="<%=(rcCountry.Fields.Item("countryName".Value)%>" <%If (Not isNull((RcCity.Fields.Item("CountryName".Value))) Then If (CStr(rcCountry.Fields.Item("countryName".Value) = CStr((RcCity.Fields.Item("CountryName".Value))) Then Response.Write("SELECTED" : Response.Write(""%> ><%=(rcCountry.Fields.Item("countryName".Value)%></option>
<%
rcCountry.MoveNext()
Wend
If (rcCountry.CursorType > 0) Then
rcCountry.MoveFirst
Else
rcCountry.Requery
End If
%>
</select>
<select name="mncity" id="mncity">
<%
While (NOT RcCity.EOF)
%>
<option value="<%=(RcCity.Fields.Item("CityName".Value)%>"><%=(RcCity.Fields.Item("CityName".Value)%></option>
<%
RcCity.MoveNext()
Wend
If (RcCity.CursorType > 0) Then
RcCity.MoveFirst
Else
RcCity.Requery
End If
%>
</select>
<input type="submit" name="Submit" value="Search" />
</form> </td>
<td >  </td>
</tr>
<tr>
<td class="SearchRow">Country Link:</td>
<td class="SearchRow" >City Link:</td>
<td class="SearchRow">Our last trip</td>
</tr>
<tr>
<td > </td>
<td > </td>
<td rowspan="2">image last date</td>
</tr>
<tr>
<td class="SearchRow">Date</td>
<td> </td>
</tr>
</table></td>

</table></td>
</tr>
</table>
</body>
</html>
<%
rcCountry.Close()
Set rcCountry = Nothing
%>
<%
RcCity.Close()
Set RcCity = Nothing
%>

Please could you help me.

Edited by - mayou on 15 Oct 2004 22:02:24

Edited by - mayou on 16 Oct 2004 01:13:47

Reply to this topic