使用文本框onchange和ajax加载进行下拉jQuery-PHP-MYSQL
我必须这样做,这是我的代码 完成“开始日期”和“结束日期”后,我需要启用“作者选择”框。 作者姓名应根据开始和结束日期从数据库中动态加载。 我的表单已经准备好了,脚本是用我的最少知识完成的。需要一些专家帮助来完成我的代码 在这方面的任何帮助都将是非常可观的使用文本框onchange和ajax加载进行下拉jQuery-PHP-MYSQL,php,jquery,html,ajax,jquery-ui,Php,Jquery,Html,Ajax,Jquery Ui,我必须这样做,这是我的代码 完成“开始日期”和“结束日期”后,我需要启用“作者选择”框。 作者姓名应根据开始和结束日期从数据库中动态加载。 我的表单已经准备好了,脚本是用我的最少知识完成的。需要一些专家帮助来完成我的代码 在这方面的任何帮助都将是非常可观的 <script type="text/javascript"> $("#to_date_change").change('input',function() { $('#author_code').prop
<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.
});
答案已经在您的标签上了:使用AJAX,使用用户输入,从服务器请求值,选择一些数据,返回响应,使用服务器的响应并循环每一行Hello,我的名字是代码缩进。我的荣幸。无论如何,使用AJAX,正如您在标记中建议的那样:。你曾经使用过吗?@ USER350885,你认为这个答案是正确的吗?