工作与文本框onchange和ajax加载下拉jQuery PHP MYSQL


Working with text box onchange and ajax load for dropdown jQuery PHP MYSQL

我必须这样做这是我的代码

  1. 当开始和结束日期完成后,我需要启用作者选择框。
  2. 作者的名字应该根据开始和结束的日期从数据库中动态加载。

我的表单准备好了,脚本用我最小的知识完成了。需要一些专家帮助完成我的代码。

如果有任何帮助,我将非常感激。

<script type="text/javascript">
    $("#to_date_change").change('input',function() {
        $('#author_code').prop('disabled', false);
    });
</script>
<table>
    <thead>
        <tr>
            <th class="text-center">Start Date</th>
            <th class="text-center">End Date</th>
            <th class="text-center">Resources</th>
        </tr>
    </thead>
    <tbody>
        <?php for($i=1; $i<=5; $i++) { ?>
        <tr>
            <td>
                <input class="start_date_change" id="start_date_change" name="from_date_<?php echo $i; ?>" type="text">
            </td>
            <td>
                <input class="end_date_change" id="end_date_change" name="to_date_<?php echo $i; ?>" type="text">
            </td>
            <td class="text-justify" nowrap="nowrap">
                <select disabled="disabled" name="author_code_<?php echo $i; ?>" id="author_code" class="author_code" style="width: 250px;">
                    <option value="">Select Author</option>
                    <?php 
                    // ............. this should come from ajax load based on start and end date ................
                    echo "<option value=".$tbemp[$r][0].">".$tbemp[$r][0]." - ".$tbemp[$r][2]."</option>";
                    // ............. this should come from ajax load based on start and end date ................
                    ?>
                </select>
            </td>
        </tr>
        <?php } ?>
    </tbody>
</table>

使用ajax调用发送数据和获取结果,使用该结果显示。

var start_date,end_date;
//fetch and assign the date to these variables
$.ajax({
    url: "/path/to/script/for/processing",
    type: "post",
    data: {start: start_date,end: end_date}
}).done(function(data){
    //data contains the result returned from the script. 
    // use that data to display.
});