DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   two commbox problem (http://www.daniweb.com/forums/thread155391.html)

rohitrohitrohit Nov 5th, 2008 5:10 am
two commbox problem
 
hi all,
i made two commbox in my page cropcat,subcat.my coding is below.when i select a item form cropcat related subcat fetch from database mysql and displayed.but my problem here is that when i select item form cropcat page refresh and selected value not display in cropcat ?please help me
  
                          <form name="form1" id="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="18%">&nbsp;</td>
    <td width="71%">&nbsp;</td>
    <td width="5%">&nbsp;</td>
    <td width="6%">&nbsp;</td>
  </tr>
  <tr>
    <td><select name="cropcat" id="cropcat" onchange=oneG()>
            <option value="0">Select Crop...</option>
            <option value="OffSeasonVEG">OffSeasonVEG</option>
            <option value="MedicinalPlants">MedicinalPlants</option>
            <option value="Floriculture">Floriculture</option>
            <option value="Pulses">Pulses</option>
          </select></td>
                 
    <td><span class="style121">
    <?php
    // echo "Connected MySql";
        $cc=$_POST['cropcat'];
        //echo "ccc".$cc;
  $res1 = mysql_query("SELECT subcat FROM crop_detail where cropcat='$cc'") or die("Invalid query: " . mysql_query());
  //echo ".mysql_query()";
  echo '<select  id="gp" name="gp" onchange=oneG()>';
  echo '<option value="">select...</option>';
  while ($row1= mysql_fetch_array($res1))
  {
    $g = $row1['subcat'];
    echo "<option value='$g'>$g</option>";
  }
  echo '</select>';
 ?>
    </span></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
..................
<script language="javascript">
function oneG()
{
        document.form1.submit();
}
</script>

pritaeas Nov 5th, 2008 7:38 am
Re: two commbox problem
 
the one that is selected is in $_POST['cropcat']. You can use it to add the selected attribute of one of the options.


All times are GMT -4. The time now is 1:01 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC