0
   < input id="cc" class="easyui-combobox" name="dept"
   data-options="valueField:'id',textField:'text',url:'get_data.php'">

这是用于创建 jquery easyui 组合框的代码。任何人都可以帮助我如何在get_data.php中编写 php 代码。这意味着例如,假设有一个名为DEPT的表,其中包含两个列 dep_iddep_name。我想在组合框中显示 dep_name 并将valueField 显示为 dep_id。

4

1 回答 1

0

I use this all the time, and there is no call to a seperate php file to get the results:

    <label for="cc">Name of DDB here</label>
                    <select id="cc" name="cc" style="width: 300px">
                        <option value="">--Select ?--</option>
                        <?php
                        $query = "SELECT dep_id, dep_name FROM YOUR TABLE HERE ORDER BY dep_name";
                        $result = $conn->query($query);
                        while ($row = $result->fetch_assoc()) {
                            echo '<option value="' . $row['dep_id'] . '" >' . $row['dep_name'] . '</option>';
                        }
                        ?>
                    </select>

and all of this goes right where you want your drop down box.

于 2013-09-19T12:55:40.630 回答