Greetings and good morning / nite to all out there
I am working on a triple combo box that is populated by 3 successive calls to a the database..it pretty near works ..however there are a few (maybe lots ) of bugs in it..
the problem I am having is that it does not hold the values thru out the script . The script I am making would be a script that allows someone to register... they choose the country, then state, then city ... depending on their previous selection a new select field would be populated based on this...
any help would be greatly appreciated..God Bless
<?php
// included database connections
echo"
<script language='JavaScript'>
<!--
function gotourl(form) {
if (form.navig.options[form.navig.selectedIndex].value != 'nogo'){
location.href = (form.navig.options[form.navig.selectedIndex].value)
}
}
//-->
</script>
";
echo"<body bgcolor=white leftmargin='0' rightmargin='0' topmargin='0' bottommargin='0' marginheight='0' marginwidth='0'>";
/*start countries this is the first form
result when 'onchange' is executed
[url]http://codelancer.com/luxuryhometrader/test.php?&country_id=1[/url]
I am happy with this so far
*/
echo"
<form name='navig' method='post' action=''>
<select name='navig' onChange='gotourl(this.form)' class=form180>
<option value='test.php'>------- SELECT ONE -------</option>";
$query1="Select * FROM countries";
$result=mysql_query($query1);
while ($row = mysql_fetch_array($result)){
if($country_id!==$row[country_id]){
echo "<option value='test.php?&country_id=$row[country_id]'>$row[country_name]</option>";
}
else{
echo "<option value='test.php?&country_id=$row[country_id]'selected>$row[country_name]</option>";
}
}
echo"</select></form><br>
</FORM>";
/*
start states
result when 'onchange' is executed
[url]http://codelancer.com/luxuryhometrader/test.php?&country_id=1&state_id=1[/url]
I am happy with this so far as the country id and state id are passed to the url ..however when I click the third form below I get this result
url]http://codelancer.com/luxuryhometrader/test.php?&country_id=&state_id=1&city_id=3[/url]
the country id value is not there :( and the two upper select fields do not hold their values
*/
echo"
<form name='navig' method='post' action=''>
<select name='navig' name='navig' onChange='gotourl(this.form)' class=form180>
<option value='test.php'>------- SELECT ONE -------</option>";
$query2="Select * FROM states WHERE country_id='$country_id'";
$result=mysql_query($query2);
while ($row = mysql_fetch_array($result)){
if($state_id!==$row[state_id]){
echo "<option value='test.php?&country_id=$row[country_id]&state_id=$row[state_id]'>$row[state_name]</option>";
}
else{
echo "<option value='test.php?&country_id=$row[country_id]&state_id=$row[state_id]'selected>$row[state_name]</option>";
}
}
echo"</select></form><br>
</FORM>";
//start cities
echo"
<form name='navig' method='post' action=''>
<select name='navig' name='navig' onChange='gotourl(this.form)' class=form180>
<option value='test.php'>------- SELECT ONE -------</option>";
$query3="Select * FROM cities WHERE state_id=$state_id";
$result=mysql_query($query3);
while ($row = mysql_fetch_array($result)){
if($state_id!==$row[state_id]){
echo"<option value='test.php?&country_id=$country_id&state_id=$row[state_id]&city_id=$row[city_id]'>$row[city_name]</option>";
}
else{
echo"<option value='test.php?&country_id=$country_id&state_id=$row[state_id]&city_id=$row[city_id]'selected>$row[city_name]</option>";
}
}
echo"</select></form><br>";
echo"
</body>
</html>";
?>
Thanks in advance and God Bless