Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //autocomplete script
- $(document).on('focus','.autocomplete_txt',function(){
- type = $(this).data('type');
- if(type =='id_barang' )autoTypeNo=0; // what this mean auttype=0;
- if(type =='sni_barang' )autoTypeNo=1; // what this mean auttype=1;
- $(this).autocomplete({
- source: function( request, response ) {
- $.ajax({
- url: '<?php echo site_url("admin/product") ?>',
- dataType: "json",
- method: 'post',
- data: {
- name_startsWith: request.term, //it will throw to sql ya what this mean ?
- type: type //also this
- },
- success: function( data ) {
- response( $.map( data, function( item ) {
- var code = item.split("|");
- return {
- label: code[autoTypeNo],
- value: code[autoTypeNo],
- data : item
- }
- }));
- }
- });
- },
- autoFocus: true,
- minLength: 0,
- select: function( event, ui ) {
- var names = ui.item.data.split("|");
- id_arr = $(this).attr('id');
- id = id_arr.split("_");
- //taruh di id item no
- $('#itemNo_'+id[1]).val(names[0]);
- //taruh di id itemname
- $('#itemName_'+id[1]).val(names[1]);
- $('#StockName_'+id[1]).val(names[2]);
- $('#kategori_'+id[1]).val(names[5]);
- $('#brand_'+id[1]).val(names[4]);
- $('#ket_'+id[1]).val(names[7]);
- //old price
- $('#old_price_'+id[1]).val(names[3]);
- quantity=$('#quantity_'+id[1]).val();
- price=$('#price_'+id[1]).val(names[3]);
- $('#total_'+id[1]).val(price*quantity);
- calculateTotal();
- }
- });
- });
- <!--my sql-->
- $type = $_POST['type']; //it came from jquery but don't know how it coming
- $name = $_POST['name_startsWith']; //it came from jquery but don't know how it coming
- $query = "SELECT * FROM `tabel_barang` where UPPER($type) LIKE '".strtoupper($name)."%' and jumlah_all > 0 group by id_barang";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement