ajax php sql populate dependent comboboxes -


i'm beginner php ajax things. populate 1 of combobox database can't populate second one.

i need populate machine combobox according proses value. , fill envanter no id. help! here code

my database table main

process | machine | id
bolzen | m1 | 1
bolzen | m2 | 2
bolzen | m3 | 3
platte | m4 | 5
platte | m4 | 7

here code

<html> <body> <div id="content"  style="background-color:#eeeeee;position:absolute; overflow:hidden; left:138px; top:101px; width:770px; height:450px">  <form action="" name="myform" id="myform">   <p><center> mft1.2 spc girisleri Ölcüm programi</center></p>     <center><p> tarih:&nbsp&nbsp <span id="mydate"> </span>     &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp     <script type="text/javascript">     date();     </script>     machine no:     <select name="machine">         <option value="000" selected = "selected"></option>               </select>                </center></p>      <center><p>     vardiya:&nbsp&nbsp         <select name="vardiya">             <option value="000" selected="selected" >             </option>             <option>               1. vardiya             </option>             <option>               2. vardiya             </option>             <option>               3. vardiya             </option>         </select>        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp                 envanter no:     <input type="text" name="envanter" disabled="disabled"/>     </center></p>     <center><p>      proses:&nbsp&nbsp              <?php         // load field datas list box              $cn=mysql_connect("localhost","root","12345678") or die("note: " . mysql_error());             $res=mysql_select_db("olcumtakip",$cn) or die("note: " . mysql_error());             $res=mysql_query("select distinct proses main;") or die("note: " . mysql_error());             ?>         <select name="proses">             <option value="000" selected = "selected"></option>          <?php         while($ri = mysql_fetch_array($res))         {         echo "<option value=" .$ri['proses'] . ">" . $ri['proses'] . "</option>";         }         echo "</select> ";          mysql_close($cn);         ?>            </center></p>     <input type="submit" value="submit" style ="margin-left:350px"/>  </form> </div> </body> </html> 

i suggest use jquery make ajax request, it's more easy. know how proccess should be, can read examples in posts below:

http://www.snilesh.com/resources/jquery/jquery-dynamic-selectbox/

http://www.codingcereal.com/2009/09/autopopulate-select-dropdown-box-using-jquery/

i hope guides can you.


Comments