My code is Functioning but I think ive been working too long on this cause Im not able to make the last 2 things work that i need for the final form.
I need the Currently selected countryname to showup to the right of the State/Province dropdown field.
If you select a country that doesnt have a state/provence That field should dissappear.
I hope someone can help cause my brain is FRIED! :_P
-------------Code below------------
<?
include("config.php");
$objConn=mysql_connect($Host,$DBUser,$DBPass);
mysql_select_db($DBName2,$objConn);
$showcountry=${"showcountry"};
if ($showcountry=="")
{
$showcountry=224;
}
else
{
$showcountry=intval($showcountry);
}
?>
<script>
function swapit(id){
document.regform.showcountry.value = id
document.regform.action = "seltest.php"
document.regform.submit()
}
</script>
<form name="regform" method="post" action="somefile.php">
<input type="hidden" name="showcountry" value="<? echo ${"showcountry"}; ?>">
<Select name="country" onchange="swapit(this.options[this.options.selectedIndex].value)">
<option value="-1"> chose a country </option>
<?
$res_query=mysql_query(("Select * from country"),$objConn);
$res=mysql_fetch_array($res_query);
while(!($res==0))
{
$countryid=$res["id"];
$countryname=$res["countryname"];
?>
<option value="<? echo $countryid; ?>" <? if ($countryid==$showcountry)
{
?>selected<? } ?>><? echo $countryname; ?></option>
<?
$res=mysql_fetch_array($res_query);
}
?>
</select>
<? if ($showcountry!="")
{
?>
<Select name="state_province">
<?
$res_query=mysql_query(("Select * from state_province where countryid = '".$showcountry."'"),$objConn);
$res=mysql_fetch_array($res_query);
while(!($res==0))
{
$areaid=$res["id"];
$state_province=$res["state_province"];
$countryid=$res["countryid"];
?>
<option value="<? echo $state_province; ?>"><? echo $state_province; ?></option>
<?
$res=mysql_fetch_array($res_query);
}
?>
</select>
<? } ?>
</form>
<?
mysql_close($objConn);
?>