查看:
<div class="form-group">
<label for="regular" class="col-sm-2 control-label">Cari</label>
<div class="col-sm-10">
<select class="form-control" id="cari" name="cari" required>
<option>Silahkan Pilih</option>
<?php foreach($cari_komponen as $row){ ?>
<option value="<?php echo $row['id_komponen'] ?>"><?php echo $row['kdgiat'] ?> - <?php echo $row['kdoutput'] ?> - <?php echo $row['kdkmpnen'] ?> - <?php echo $row['urkmpnen'] ?></option>
<?php } ?>
</select>
<div class="form-control-line"></div>
</div>
</div>
<div class="form-group">
<label for="regular" class="col-sm-2 control-label">Kode Kegiatan</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="kode_kegiatan" name="kode_kegiatan" required="required" disabled><div class="form-control-line"></div>
</div>
</div>
<div class="form-group">
<label for="regular" class="col-sm-2 control-label">Kode Output</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="kode_output" name="kode_output" required="required" disabled><div class="form-control-line"></div>
</div>
</div>
<div class="form-group">
<label for="regular" class="col-sm-2 control-label">Kode Sub Output</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="kode_sub_output" name="kode_sub_output" required="required" disabled><div class="form-control-line"></div>
</div>
</div>
<div class="form-group">
<label for="regular" class="col-sm-2 control-label">Kode Komponen</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="kode_komponen" name="kode_komponen" required="required"><div class="form-control-line"></div>
</div>
</div>
<div class="form-group">
<label for="regular" class="col-sm-2 control-label">Uraian Komponen</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="uraian_komponen" name="uraian_komponen" required="required" disabled><div class="form-control-line"></div>
</div>
</div>
<div class="form-group">
<label for="regular" class="col-sm-2 control-label">Kode Sub Kompenen</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="kode_sub_komponen" name="kode_sub_komponen" required="required" disabled><div class="form-control-line"></div>
</div>
</div>
<div class="form-group">
<label for="regular" class="col-sm-2 control-label">Uraian Sub Komponen</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="uraian_sub_komponen" name="uraian_sub_komponen" required="required" disabled><div class="form-control-line"></div>
</div>
</div>
Ajax帖子:
$('#cari').change(function() {
$.ajax({
url : '<?php echo base_url() ?>rekam/realisasi_anggaran/get_komponen',
type : 'POST',
dataType: 'json',
cache: false,
data : { cari: $('#cari').val() },
success: function( data ) {
if(!data['result']){
}else{
$('#kode_kegiatan').val(data['kode_kegiatan']);
$('#kode_output').val(data['kode_output']);
$('#kode_sub_output').val(data['kode_sub_output']);
$('#kode_komponen').val(data['kode_komponen']);
$('#uraian_komponen').val(data['uraian_komponen']);
$('#kode_sub_komponen').val(data['kode_sub_komponen']);
$('#uraian_sub_komponen').val(data['uraian_sub_komponen']);
}
}
});
});
$('#kode_komponen').live(function() {
$.ajax({
url : '<?php echo base_url() ?>rekam/realisasi_anggaran/get_komponens',
type : 'POST',
dataType: 'json',
data : { cari: $('#cari').val() },
success: function( data ) {
if(!data['result']){
}else{
$('#kode_kegiatan').val(data['kode_kegiatan']);
$('#kode_output').val(data['kode_output']);
$('#kode_sub_output').val(data['kode_sub_output']);
$('#kode_komponen').val(data['kode_komponen']);
$('#uraian_komponen').val(data['uraian_komponen']);
$('#kode_sub_komponen').val(data['kode_sub_komponen']);
$('#uraian_sub_komponen').val(data['uraian_sub_komponen']);
}
}
});
});
我希望获得从我的第一个ajax帖子(#kode_komponen)生成的实时值,并将其传递给另一个ajax帖子。 那可能吗?因为我尝试在#kode_komponen上使用.live或.change但它不起作用。