[Solved] stuck on a PHP program. Need some idea


Use javascript function onchange select element and fetch records according to selected first select element value.

<form name="product" method="post" >
<select id="category" name="category" onChange="relodme()">
    <option value=""></option>
    <?php
    $qry = "select * from category order by name";
    $res = mysql_query($qry) or die ("MYSQL ERROR:".mysql_error());
    while ($arr = mysql_fetch_array($res))
    {
        ?> 
            <option value="<?=$arr['category_id']?>" <? if($_POST['category'] == $arr['category_id']) { ?> selected="selected" <? } ?> ><?=$arr['name']?></option>
        <?
    }

    ?>
</select>

<select id="Type" name="Type"  >
    <option value=""></option>
    <?php
    $qry = "select * from subcategory where category_id = '".$_POST['category']."' order by name";
    $res = mysql_query($qry) or die ("MYSQL ERROR:".mysql_error());
    while ($arr = mysql_fetch_array($res))
    {
        ?> 
            <option value="<?=$arr['sub_category_id']?>" <? if($_POST['Type'] == $arr['sub_category_id']) { ?> selected="selected" <? } ?> ><?=$arr['name']?></option>
        <?
    }

    ?>
</select>
</form>

Javascript function:

function relodme()
{
   document.forms[0].action="test1.php";  //your page name give here....
   document.forms[0].submit();
}

solved stuck on a PHP program. Need some idea