two commbox problem

Thread Solved

Join Date: Oct 2007
Posts: 36
Reputation: rohitrohitrohit is an unknown quantity at this point 
Solved Threads: 2
rohitrohitrohit's Avatar
rohitrohitrohit rohitrohitrohit is offline Offline
Light Poster

two commbox problem

 
0
  #1
Nov 5th, 2008
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
  1.  
  2. <form name="form1" id="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
  3. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  4. <tr>
  5. <td width="18%">&nbsp;</td>
  6. <td width="71%">&nbsp;</td>
  7. <td width="5%">&nbsp;</td>
  8. <td width="6%">&nbsp;</td>
  9. </tr>
  10. <tr>
  11. <td><select name="cropcat" id="cropcat" onchange=oneG()>
  12. <option value="0">Select Crop...</option>
  13. <option value="OffSeasonVEG">OffSeasonVEG</option>
  14. <option value="MedicinalPlants">MedicinalPlants</option>
  15. <option value="Floriculture">Floriculture</option>
  16. <option value="Pulses">Pulses</option>
  17. </select></td>
  18.  
  19. <td><span class="style121">
  20. <?php
  21. // echo "Connected MySql";
  22. $cc=$_POST['cropcat'];
  23. //echo "ccc".$cc;
  24. $res1 = mysql_query("SELECT subcat FROM crop_detail where cropcat='$cc'") or die("Invalid query: " . mysql_query());
  25. //echo ".mysql_query()";
  26. echo '<select id="gp" name="gp" onchange=oneG()>';
  27. echo '<option value="">select...</option>';
  28. while ($row1= mysql_fetch_array($res1))
  29. {
  30. $g = $row1['subcat'];
  31. echo "<option value='$g'>$g</option>";
  32. }
  33. echo '</select>';
  34. ?>
  35. </span></td>
  36. <td>&nbsp;</td>
  37. <td>&nbsp;</td>
  38. </tr>
  39. <tr>
  40. <td>&nbsp;</td>
  41. <td>&nbsp;</td>
  42. <td>&nbsp;</td>
  43. <td>&nbsp;</td>
  44. </tr>
  45. <tr>
  46. <td>&nbsp;</td>
  47. <td>&nbsp;</td>
  48. <td>&nbsp;</td>
  49. <td>&nbsp;</td>
  50. </tr>
  51. </table>
  52. </form>
  53. ..................
  54. <script language="javascript">
  55. function oneG()
  56. {
  57. document.form1.submit();
  58. }
  59. </script>
Last edited by peter_budo; Nov 5th, 2008 at 9:00 pm. Reason: Correcting code tags, please use [code] not <code>
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 798
Reputation: pritaeas is on a distinguished road 
Solved Threads: 130
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Master Poster

Re: two commbox problem

 
0
  #2
Nov 5th, 2008
the one that is selected is in $_POST['cropcat']. You can use it to add the selected attribute of one of the options.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC