the second drop menu will get it's items from a table called city [mysql database],
with what i've done i must press the submit button to do that,
but i don't want to press any button,
i mean,
when the first item from the primary menu is selected the second menu,show the items automatically,without pressing any button
how can i do that??!!
each value in the option in the html part is equal to the id in it's table called ostan i mean
ostan table:
id,name=>1,mazandaraz
2,gilan
3,tehran
<?php
$l=mysql_connect('localhost','root','');
mysql_query('use test',$l);
$oid=$_POST['ostan'];
foreach($oid as $r)
$roid=$r;
//echo $roid.'<br>';
$qf="select id,name from ostan";
$exeqf=mysql_query($qf,$l);
while($res=mysql_fetch_array($exeqf))
{
if($res['id']==$roid)
//echo 'ostan='.$res['name'];
{
$qs="select id,name from city where oid='$roid'";
$exeqs=mysql_query($qs,$l);
echo "<select name='city'><option value=''>Select one</option>";
echo '<br>';
while($res2=mysql_fetch_array($exeqs))
{
//echo 'city='.$res2['name'];
echo "<option selected value='$res2[id]'>$res2[name]</option>"."<BR>";
}//second while
}//first if
}//first while
echo '</select>';
?>
<html><body>
<form name='form' method='post' action="<?php print $SERVER['PHP_SELF'] ?>" >
select your ostan:
<select name='ostan[]'>
<option value='' >Select One</option>
<option value='1'>mazandaran</option>
<option value='2'>gilan</option>
<option value='3'>tehran</option>
</select>
<br>
<input type='submit' value='submit'>
</form></body></html>
This post has been edited by JackOfAllTrades: 08 March 2010 - 05:05 PM
Reason for edit:: Added code tags. PLEASE!!! [code]...PUT YOUR CODE IN HERE...[/code]

New Topic/Question
Reply




MultiQuote




|