<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript">
function getSubject() {
var yr=document.getElementById("semester").value;
console.log(yr);
$.ajax({
type: "GET",
url: "dropdown.php",
data: "yr="+yr,
success: function(result) {
$("#subject").html(result);
}
});
}
</script>
根据年度学期选择年份必须使用ajax
加载另一个组合框答案 0 :(得分:-1)
$('#semester').change(function () {
$('#subject').html('<option value="" id="0">Select Subject</option>');
var yr=$(this).val();
$.ajax({
data: {'yr' : yr},
type: "GET",
url : "dropdown.php",
dataType:'json',
success:function(data)
{
for (var i = 0; i < data.length; i++) {
var result = '<option value="'+data[i]['sem_id']+'">'+data[i]['sem_name']+'</option>'
$('#subject').append(result);
}
},
error:function()
{
alert("Something Wrong..");
}
});
});