我有两个字段,一个是省,另一个是区:
<div class="form-group">
<label class="control-label col-sm-4">Province *</label>
<div class="col-sm-5">
<select id="province" name="province" class="form-control selectboxit" onchange="get_districts(this.value)" required="">
<option value="">Select Province</option>
<?php
$province = $this->db->get('provinces')->result_array();
foreach ($province as $row):
?>
<option value="<?php echo $row['provinceID']; ?>">
<?php echo $row['province_name']; ?>
</option>
<?php
endforeach;
?>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-4">District *</label>
<div class="col-sm-5">
<select id="district" name="district" class="form-control" >
<option value="" selected="selected">First Select Province</option>
</select>
</div>
</div>
脚本在这里:
<script type="text/javascript">
function get_districts(val) {
$.ajax({
url: '<?php echo base_url(); ?>index.php?admin/get_district/' + val,
success: function (response)
{
jQuery('#district').html(response);
}
});
}
function valida(val) {
if (val == "Rent") {
document.getElementById("rent_amount").disabled = false;
}
if (val == "Personal") {
document.getElementById("rent_amount").disabled = true;
}
}
</script>
在视图页面中它对我来说很好用,但是当我在pop模式中处理这些东西时,通过单击此链接无法正常工作弹出模式显示数据但ajax不工作:
<a href="#" onclick="showAjaxModal('<?php echo base_url(); ?>index.php?modal/popup/modal_branche_edit/<?php echo $row['branch_id']; ?>');">
<i class="fa fa-edit"></i>
</a>
弹出模式工作正常,但ajax无效。 请问有什么建议吗?