Hi basically my problem is I have 2 drop down menus populated by my database the first populated by a field in the database and the 2nd populated with a relation to the value selected in the first and basically i'm just havin a problem refreshing the menus after i submit a value or refresh the page. My code is below:
//javascript
//php
[PHP]
$province = $site = null; //declare vars
if(isset($_GET["province"]))
{
$province = $_GET["province"];
}
if(isset($_GET["site"]) && is_numeric($_GE T["site"]))
{
$city = $_GET["site"];
}
<form name="theForm" method="get">
<select name="province" onChange="autoS ubmit();">
<option value="null">Pr ovince</option>
<?php
//POPULATE DROP DOWN MENU WITH PROVINCES
$sql = "SELECT DISTINCT Province FROM SAMP_SITE";
$provinces = mysql_query($sq l);
while($row = mysql_fetch_arr ay($provinces))
{
echo ("<option value=\"$row[Province]\" " . ($province == $row["Province"] ? " selected" : "") . ">$row[Province]</option>");
}
?>
</select>
<br><br>
<?php
if($province != null)
{
?>
<select name="site"">
<option value="null"></option>
<?php
//POPULATE DROP DOWN MENU WITH SITES GIVEN SELECTED PROVINCE
$sql = "SELECT SiteName,SAMP_S ITE_ID FROM SAMP_SITE WHERE Province = '$province' ";
$sites = mysql_query($sq l);
while($row = mysql_fetch_arr ay($sites))
{
echo ("<option value=\"$row[SAMP_SITE_ID]\" " . ($city == $row["SAMP_SITE_ ID"] ? " selected" : "") . ">$row[SiteName]</option>");
}
?>
</select>
<?php
}
?>
<input type='image' src='searchedir t.bmp' onClick='submit '>
</form>[/PHP]
//javascript
Code:
<script language="JavaScript">
function autoSubmit()
{
var formObject = document.forms['theForm'];
formObject.submit();
}
</script>
[PHP]
$province = $site = null; //declare vars
if(isset($_GET["province"]))
{
$province = $_GET["province"];
}
if(isset($_GET["site"]) && is_numeric($_GE T["site"]))
{
$city = $_GET["site"];
}
<form name="theForm" method="get">
<select name="province" onChange="autoS ubmit();">
<option value="null">Pr ovince</option>
<?php
//POPULATE DROP DOWN MENU WITH PROVINCES
$sql = "SELECT DISTINCT Province FROM SAMP_SITE";
$provinces = mysql_query($sq l);
while($row = mysql_fetch_arr ay($provinces))
{
echo ("<option value=\"$row[Province]\" " . ($province == $row["Province"] ? " selected" : "") . ">$row[Province]</option>");
}
?>
</select>
<br><br>
<?php
if($province != null)
{
?>
<select name="site"">
<option value="null"></option>
<?php
//POPULATE DROP DOWN MENU WITH SITES GIVEN SELECTED PROVINCE
$sql = "SELECT SiteName,SAMP_S ITE_ID FROM SAMP_SITE WHERE Province = '$province' ";
$sites = mysql_query($sq l);
while($row = mysql_fetch_arr ay($sites))
{
echo ("<option value=\"$row[SAMP_SITE_ID]\" " . ($city == $row["SAMP_SITE_ ID"] ? " selected" : "") . ">$row[SiteName]</option>");
}
?>
</select>
<?php
}
?>
<input type='image' src='searchedir t.bmp' onClick='submit '>
</form>[/PHP]
Comment