pavmoxo
06-27-2006, 11:43 AM
I have 2 dropdown that I have to associate:
This is the category dropdown:
<select name="cat_ID" id="cat_ID" tabindex="3">
<?
$sql = "select cat_ID, cat_nome from cat_links order by cat_nome" ;
$query = query($sql);
$conta = mysql_num_rows($query);
for ($i=0;$i<$conta;$i++)
{
$arrl = mysql_fetch_array($query);
?>
<option value="<?php echo $arrl["cat_ID"]; ?>"><?php echo $arrl["cat_nome"]; ?></option>
<? } ?>
</select>
And this is the subcategory dropdown:
<select name="subcat_ID" id="subcat_ID" tabindex="3">
<?
$sql = "select s.subcat_ID, s.subcat_nome from subcat_links s, cat_links c where c.cat_ID = ".$arrl["cat_ID"]." order by s.subcat_nome" ;
$query = query($sql);
$conta = mysql_num_rows($query);
for ($i=0;$i<$conta;$i++)
{
$arrl = mysql_fetch_array($query);
?>
<option value="<?php echo $arrl["subcat_ID"]; ?>"><?php echo $arrl["subcat_nome"]; ?></option>
<? } ?>
</select>
What I want is when in choose a category, the subcategories will change to correpond. Can you help me??
This is the category dropdown:
<select name="cat_ID" id="cat_ID" tabindex="3">
<?
$sql = "select cat_ID, cat_nome from cat_links order by cat_nome" ;
$query = query($sql);
$conta = mysql_num_rows($query);
for ($i=0;$i<$conta;$i++)
{
$arrl = mysql_fetch_array($query);
?>
<option value="<?php echo $arrl["cat_ID"]; ?>"><?php echo $arrl["cat_nome"]; ?></option>
<? } ?>
</select>
And this is the subcategory dropdown:
<select name="subcat_ID" id="subcat_ID" tabindex="3">
<?
$sql = "select s.subcat_ID, s.subcat_nome from subcat_links s, cat_links c where c.cat_ID = ".$arrl["cat_ID"]." order by s.subcat_nome" ;
$query = query($sql);
$conta = mysql_num_rows($query);
for ($i=0;$i<$conta;$i++)
{
$arrl = mysql_fetch_array($query);
?>
<option value="<?php echo $arrl["subcat_ID"]; ?>"><?php echo $arrl["subcat_nome"]; ?></option>
<? } ?>
</select>
What I want is when in choose a category, the subcategories will change to correpond. Can you help me??