0

我只是所有这些 php ajax 东西的初学者。我从数据库中填充了我的一个组合框,但我无法填充第二个。

我需要根据 Proses 值填充 Machine 组合框。最后用 ID 填写 Envanter no。感谢帮助!这是我的代码

我的数据库表主要

工艺 | 机器 | ID
博尔岑 | M1 | 1
博尔岑 | M2 | 2
博尔岑 | M3 | 3
普拉特 | M4 | 5
普拉特 | M4 | 7

这是我的代码

<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 into 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 from 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>
4

1 回答 1

0

我建议你使用 Jquery 来发出 ajax 请求,它更容易。要了解流程应该如何,您可以阅读以下帖子中的示例:

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

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

我希望指南可以帮助你。

于 2013-07-19T15:43:43.647 回答