<!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 &gt; state &gt; town.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>As a lone php page, it works fine, but when I put 
it in&nbsp;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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&lt;?<BR>//connect to database//<BR>include 
"connect.php";</FONT></DIV>
<DIV>&nbsp;</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>&nbsp;&nbsp; 
$_SESSION['state_shc'] = $_POST['stateList'];<BR>&nbsp; $stateList = 
$_SESSION['state_shc'];<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>?&gt;<BR>&lt;SCRIPT 
language=JavaScript&gt;<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>&nbsp;</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>&lt;/script&gt;<BR>&lt;?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>$query&nbsp; = "SELECT country_shc, country_name 
FROM countries ORDER BY country_shc";<BR>$result = 
mysql_query($query);<BR>$country_shc = 
$_SESSION['country_shc'];<BR>?&gt;<BR>&lt;form name="form1" action="" 
method="post"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;select 
onChange='form1.submit();' name='countryList'&gt;<BR>&lt;?<BR>while($row = 
mysql_fetch_array($result, MYSQL_ASSOC))<BR>{<BR>echo "&lt;option 
value='{$row['country_shc']}'";<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; if 
($countryId == $row['country_shc'])<BR>&nbsp;&nbsp; echo 
"selected";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; echo 
"&gt;{$row['country_name']}&lt;/option&gt;";<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>?&gt;<BR>&lt;/select&gt;<BR>&lt;/form&gt;<BR>&lt;?<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
$_SESSION['country_shc'] = 
$_POST['countryList'];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $_SESSION['stateId'] = 
$_POST['stateList'];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $query&nbsp; = "SELECT state_shc, state_name 
FROM states WHERE country_shc = 
'$country_shc'";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $result = 
mysql_query($query);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
?&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;form name="form2" action="" 
method="post"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;select 
onChange='form2.submit();' 
name='stateList'&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;?<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
while($row = mysql_fetch_array($result, 
MYSQL_ASSOC))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 
"&lt;option 
value='{$row['state_shc']}'";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
($stateId == 
$row['state_shc'])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
echo "selected";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 
"&gt;{$row['state_name']}&lt;/option&gt;";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;/select&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type="hidden" 
name="countryList" value="&lt;?=$_SESSION['country_shc'];?&gt;" 
/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;/form&gt;<BR>&lt;?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $_SESSION['state_shc'] = 
$_POST['stateList'];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $state_shc = 
$_SESSION['state_shc'];</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $_SESSION['cityId'] 
= $_POST['cityList'];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $query&nbsp; = "SELECT 
city_id, city_name FROM cities WHERE state_shc = 
'$state_shc'";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $result = 
mysql_query($query);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
?&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;select 
name='cityList'&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;?<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while($row = mysql_fetch_array($result, 
MYSQL_ASSOC))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 
"&lt;option 
value='{$row['city_shc']}'";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
($cityId == 
$row['city_shc'])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
echo "selected";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 
"&gt;{$row['city_name']}&lt;/option&gt;";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>?&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;/select&gt;</FONT></DIV></BODY></HTML>