<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16414" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I have put together this drop down code to drill
down from country > state > town.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>As a lone php page, it works fine, but when I put
it in block on a drupal page, the countries load, but when I select, say,
Canada, the page refreshes as it should but the United States is always there,
not Canada.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Possibly it's a problem relating to the javascript,
the self.location maybe. I'd appreciate any help with this one.</FONT></DIV>
<DIV><FONT face=Arial
size=2>----------------------------------------------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><?<BR>//connect to database//<BR>include
"connect.php";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>//start session//<BR>session_start();<BR>//update
session if country selection
changed//<BR>if(isset($_POST['countryList']))<BR>{<BR>if(isset($_POST['stateList']))<BR>
$_SESSION['state_shc'] = $_POST['stateList'];<BR> $stateList =
$_SESSION['state_shc'];<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>?><BR><SCRIPT
language=JavaScript><BR>function reload(form)<BR>{<BR>// Setting the variable
with the value of selected country's ID<BR>var
val=populate.countryList.options[populate.countryList.options.selectedIndex].value;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>// Sending the country id in the query string to
retrieve the city list<BR>self.location='index.php?countryId=' + val
;<BR>}<BR></script><BR><?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>$query = "SELECT country_shc, country_name
FROM countries ORDER BY country_shc";<BR>$result =
mysql_query($query);<BR>$country_shc =
$_SESSION['country_shc'];<BR>?><BR><form name="form1" action=""
method="post"><BR> <select
onChange='form1.submit();' name='countryList'><BR><?<BR>while($row =
mysql_fetch_array($result, MYSQL_ASSOC))<BR>{<BR>echo "<option
value='{$row['country_shc']}'";<BR> <BR> if
($countryId == $row['country_shc'])<BR> echo
"selected";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> echo
">{$row['country_name']}</option>";<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>?><BR></select><BR></form><BR><?<BR>
$_SESSION['country_shc'] =
$_POST['countryList'];<BR> $_SESSION['stateId'] =
$_POST['stateList'];<BR>
<BR> $query = "SELECT state_shc, state_name
FROM states WHERE country_shc =
'$country_shc'";<BR> $result =
mysql_query($query);<BR>
?><BR> <form name="form2" action=""
method="post"><BR> <select
onChange='form2.submit();'
name='stateList'><BR>
<BR> <?<BR>
while($row = mysql_fetch_array($result,
MYSQL_ASSOC))<BR>
{<BR> echo
"<option
value='{$row['state_shc']}'";<BR>
<BR> if
($stateId ==
$row['state_shc'])<BR>
echo "selected";<BR>
<BR> echo
">{$row['state_name']}</option>";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
}<BR> ?><BR>
</select><BR> <input type="hidden"
name="countryList" value="<?=$_SESSION['country_shc'];?>"
/><BR>
</form><BR><?
<BR> $_SESSION['state_shc'] =
$_POST['stateList'];<BR> $state_shc =
$_SESSION['state_shc'];</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> $_SESSION['cityId']
= $_POST['cityList'];<BR> $query = "SELECT
city_id, city_name FROM cities WHERE state_shc =
'$state_shc'";<BR> $result =
mysql_query($query);<BR>
?><BR> <select
name='cityList'><BR>
<?<BR> while($row = mysql_fetch_array($result,
MYSQL_ASSOC))<BR>
{<BR> echo
"<option
value='{$row['city_shc']}'";<BR>
<BR> if
($cityId ==
$row['city_shc'])<BR>
echo "selected";<BR>
<BR> echo
">{$row['city_name']}</option>";<BR>
<BR> }<BR>?><BR>
</select></FONT></DIV></BODY></HTML>