943,590 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 476
  • PHP RSS
Nov 5th, 2008
0

two commbox problem

Expand Post »
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
PHP Syntax (Toggle Plain Text)
  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>
Reputation Points: 15
Solved Threads: 5
Junior Poster
rohitrohitrohit is offline Offline
120 posts
since Oct 2007
Nov 5th, 2008
0

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.
Sponsor
Featured Poster
Reputation Points: 549
Solved Threads: 722
Bite my shiny metal ass!
pritaeas is offline Offline
4,156 posts
since Jul 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Form Validation ???
Next Thread in PHP Forum Timeline: How to make website submitter??





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC