我的脚本中有自动完成,
我需要附加一个自动完成的多个id或元素,
但剧本只是读了我写的最后一个答案
请帮帮我
$("#inputProdukEdisi").autocomplete({
source: function(request, response) {
$.ajax({
url: BASE_URL+'setup_edisi/getParameterProduk',
dataType: "json",
data: {
term : request.term,
produk : $('#inputProdukCode').val()
},
success: function(data) {
response($.map(data, function(v,i){
return {
label: v.label,
value: v.value,
name: v.name,
tanggal: v.tanggal_terbit
};
}));
}
});
},
select:function(event, ui){
$('#inputTanggalAwal').val(ui.item.tanggal);
},
min_length: 1
//delay: 300
});
$("#inputProdukEdisi").autocomplete("option", "appendTo", "#editMediaOrder");
$("#inputProdukEdisi").autocomplete("option", "appendTo", "#AddMediaOrder");
答案 0 :(得分:0)
<div id="editMediaOrder" class="modal fade bs-example-modal-lg modal-info" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Edit Detail Order</h4>
</div>
<div class="modal-body modal-scroll">
<!-- form start -->
<form class="form-horizontal" role="form" id="FormIDDetailMediaOrder" name="FormDetailMediaOrder" action="" method="post">
<div class="box-body">
<div class="form-group">
<label for="inputJenisIklan" class="col-sm-2 control-label">Jenis Iklan <span class="asterisk">*</span></label>
<div class="col-sm-3">
<input type="text" class="form-control" id="inputJenisIklan" name="inputJenisIklan" placeholder="Jenis Iklan" autocomplete="off" value="{$item->JenisCode}{set_value('inputJenisIklan',$inputJenisIklan)}" onclick="ShowListJenisIklanSaja()" style="cursor:pointer;">
<input type="hidden" id="inputJenisJenis" name="inputJenisJenis" value="{set_value('inputJenisJenis',$inputJenisJenis)}">
{form_error('inputJenisIklan','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputProdukEdisi" class="col-sm-2 control-label">Edisi <span class="asterisk">*</span></label>
<div class="col-sm-3">
<input type="text" class="form-control" id="inputProdukEdisi" name="inputProdukEdisi" placeholder="Edisi" autocomplete="off" value="{$item->Edisi}{set_value('inputProdukEdisi',$inputProdukEdisi)}"{if (getJenisIklan($item->JenisCode) == 0)}readonly{else if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputProdukEdisi','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputMingguKe" class="col-sm-2 control-label">Minggu Ke <span class="asterisk">*</span></label>
<div class="col-sm-4">
{html_options name="inputMingguKe" id="inputMingguKe" class="form-control" options=listMingguKe() selected=$inputMingguKe disabled="true"}
{form_error('inputMingguKe','<p class="text-danger">', '</p>')}
<input type="text" class="hide" id="inputMingguKe"/>
</div>
</div><!-- /.form-group -->
<div class="form-group">
<label for="inputEvent" class="col-sm-2 control-label">Event</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="inputEvent" name="inputEvent" placeholder="Masukkan Nama Event" autocomplete="off" value="{$item->Acara}{set_value('inputEvent',$inputEvent)}" {if (getJenisIklan($item->JenisCode) == 1)}readonly{else if ($item->FKwit == 1)}readonly{/if}>
<input type="hidden" id="inputEventID" name="inputEventID" value="{$item->AcaraID}{set_value('inputEventID',$inputEventID)}">
{form_error('inputEvent','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputHarga" class="col-sm-2 control-label">Harga</label>
<div class="col-sm-5">
<input type="text" class="form-control Money" id="inputHarga" name="inputHarga" placeholder="Harga" autocomplete="off" value="{$item->Harga}{set_value('inputHarga',$inputHarga)}" {if (getJenisIklan($item->JenisCode) == 0)}readonly{else if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputHarga','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">(mm/hal/mgg)</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="inputMM" name="inputMM" placeholder="0" autocomplete="off" value="{$item->Mm}{set_value('inputMM',$inputMM)}" onkeyup="Hitung(1,this.value)" {if (getJenisIklan($item->JenisCode) == 0)}readonly{else if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputMM','<p class="text-danger">', '</p>')}
</div>
<div class="col-sm-3">
<input type="text" class="form-control" id="inputKol" name="inputKol" placeholder="0" autocomplete="off" value="{$item->Kol}{set_value('inputKol',$inputKol)}" onkeyup="Hitung(2,this.value)" {if (getJenisIklan($item->JenisCode) == 0)}readonly{else if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputKol','<p class="text-danger">', '</p>')}
</div>
</div><br> <br>
<div class="form-group">
<label for="inputJumlah" class="col-sm-2 control-label">Jumlah</label>
<div class="col-sm-3">
<input type="text" class="form-control Money" id="inputJumlah" name="inputJumlah" placeholder="Jumlah" autocomplete="off" value="{$item->Jumlah}{set_value('inputJumlah',$inputJumlah)}" readonly="true">
{form_error('inputJumlah','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputDisc1Persen" class="col-sm-2 control-label">Disc1 (%)</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="inputDisc1Persen" name="inputDisc1Persen" placeholder="0%" autocomplete="off" value="{$item->Disc1}{set_value('inputDisc1Persen',$inputDisc1Persen)}" onkeyup="Hitung(3,this.value)" {if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputDisc1Persen','<p class="text-danger">', '</p>')}
</div>
<label for="inputDisc1Rp" class="col-sm-2 control-label">Disc1 (Rp)</label>
<div class="col-sm-3">
<input type="text" class="form-control Money" id="inputDisc1Rp" name="inputDisc1Rp" placeholder="0%" autocomplete="off" value="{$item->Disc1Rp}{set_value('inputDisc1Rp',$inputDisc1Rp)}" onkeyup="Hitung(4,this.value)" {if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputDisc1Rp','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputDisc2Persen" class="col-sm-2 control-label">Disc2 (%)</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="inputDisc2Persen" name="inputDisc2Persen" placeholder="0%" autocomplete="off" value="{$item->Disc2Rp}{set_value('inputDisc2Persen',$inputDisc2Persen)}" onkeyup="Hitung(5,this.value)" {if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputDisc2Persen','<p class="text-danger">', '</p>')}
</div>
<label for="inputDisc2Rp" class="col-sm-2 control-label">Disc2 (Rp)</label>
<div class="col-sm-3">
<input type="text" class="form-control Money" id="inputDisc2Rp" name="inputDisc2Rp" placeholder="0%" autocomplete="off" value="{$item->Disc2Rp}{set_value('inputDisc2Rp',$inputDisc2Rp)}" onkeyup="Hitung(6,this.value)" {if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputDisc2Rp','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputBiaya" class="col-sm-2 control-label">Biaya</label>
<div class="col-sm-3">
<input type="text" class="form-control Money" id="inputBiaya" name="inputBiaya" placeholder="Rp 0,-" autocomplete="off" value="{$item->Biaya}{set_value('inputBiaya',$inputBiaya)}" onkeyup="Hitung(7,this.value)" {if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputBiaya','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputTotal" class="col-sm-2 control-label">Subtotal</label>
<div class="col-sm-3">
<input type="text" class="form-control Money" id="inputDPP" name="inputDPP" placeholder="Rp 0,-" autocomplete="off" value="{$item->Dpp}{set_value('inputDPP',$inputDPP)}" align="right" disabled="true">
{form_error('inputDPP','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputTotal" class="col-sm-2 control-label">PPN</label>
<div class="col-sm-3">
<input type="text" class="form-control Money" id="inputPPNRp" name="inputPPNRp" placeholder="0%" autocomplete="off" value="{$item->PPNRp}{set_value('inputPPNRp',$inputPPNRp)}" readonly="true" align="right">
{form_error('inputPPNRp','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputTotal" class="col-sm-2 control-label">Total</label>
<div class="col-sm-3">
<input type="text" class="form-control Money" id="inputTotal" name="inputTotal" placeholder="Rp 0,-" autocomplete="off" value="{$item->Total}{set_value('inputTotal',$inputTotal)}" disabled="true" align="right">
{form_error('inputTotal','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Tanggal Awal</label>
<div class="col-sm-3">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control" id="inputTanggalAwal" name="inputTanggalAwal" value="{$item->TglTerbit}{set_value('inputTanggalAwal',$inputTanggalAwal)}" data-inputmask="'alias': 'yyyy/mm/dd'" data-mask onkeypress="SetValueAkhir(event)" {if (getJenisIklan($item->JenisCode) == 1)}readonly{else if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputTanggalAwal','<p class="text-danger">', '</p>')}
</div>
</div>
<label for="inputTotal" class="col-sm-2 control-label">Tanggal Berakhir</label>
<div class="col-sm-3">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control" id="inputTanggalAkhir" name="inputTanggalAkhir" value="{$item->TglAkhir}{set_value('inputTanggalAkhir',$inputTanggalAkhir)}" data-inputmask="'alias': 'yyyy/mm/dd'" data-mask {if (getJenisIklan($item->JenisCode) == 1)}readonly{else if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputTanggalAkhir','<p class="text-danger">', '</p>')}
</div>
</div>
</div>
<div class="form-group">
<label for="inputStatus" class="col-sm-2 control-label">Status <span class="asterisk">*</span></label>
<div class="col-sm-4">
{html_options name="inputStatus" id="inputStatus" class="form-control" options=listStatusBayar() selected=$inputStatus disabled="true"}
{form_error('inputStatus','<p class="text-danger">', '</p>')}
<input type="text" class="hide" id="inputStatus" value="{$item->Status}" />
</div>
</div>
<div class="form-group">
<label for="inputJudulIklan" class="col-sm-2 control-label">Keterangan/Judul Iklan</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="inputJudulIklan" name="inputJudulIklan" placeholder="..." autocomplete="off" value="{$item->Keterangan}{set_value('inputJudulIklan',$inputJudulIklan)}" {if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputJudulIklan','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputLokasiAcara" class="col-sm-2 control-label">Versi/Lokasi Acara</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="inputLokasiAcara" name="inputLokasiAcara" placeholder="..." autocomplete="off" value="{$item->Versi}{set_value('inputLokasiAcara',$inputLokasiAcara)}" {if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputLokasiAcara','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputPosisiHalaman" class="col-sm-2 control-label">Posisi Halaman</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="inputPosisiHalaman" name="inputPosisiHalaman" placeholder="..." autocomplete="off" value="{$item->Posisi}{set_value('inputPosisiHalaman',$inputPosisiHalaman)}" {if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputPosisiHalaman','<p class="text-danger">', '</p>')}
</div>
</div>
<div class="form-group">
<label for="inputPoCustomer" class="col-sm-2 control-label">PO Customer</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="inputPoCustomer" name="inputPoCustomer" placeholder="..." autocomplete="off" value="{$item->PoCust}{set_value('inputPoCustomer',$inputPoCustomer)}" {if ($item->FKwit == 1)}readonly{/if}>
{form_error('inputPoCustomer','<p class="text-danger">', '</p>')}
</div>
</div><br>
</div><!-- /.box-body -->
</form>
</div>
<div class="modal-footer">
<button class="btn btn-outline pull-left" data-dismiss="modal" type="button">Tutup</button>
<button class="btn btn-outline" type="button" onclick="SimpanDetail()">Tampilkan</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
答案 1 :(得分:0)
为什么不使用'class'选择器而不是'Id',所以它会附加到所有匹配的类。
javascript:
$("#inputProdukEdisi").autocomplete("option", "appendTo", ".autocomplete-append");
html元素:
<div id="editMediaOrder" class="modal fade bs-example-modal-lg modal-info autocomplete-append" tabindex="-1" role="dialog" aria-hidden="true">
...