Advertisement
freddy0512

jake

Oct 4th, 2015
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. //autocomplete script
  2. $(document).on('focus','.autocomplete_txt',function(){
  3. type = $(this).data('type');
  4. if(type =='id_barang' )autoTypeNo=0; // what this mean auttype=0;
  5. if(type =='sni_barang' )autoTypeNo=1; // what this mean auttype=1;
  6. $(this).autocomplete({
  7. source: function( request, response ) {
  8. $.ajax({
  9. url: '<?php echo site_url("admin/product") ?>',
  10. dataType: "json",
  11. method: 'post',
  12. data: {
  13. name_startsWith: request.term, //it will throw to sql ya what this mean ?
  14. type: type //also this
  15. },
  16. success: function( data ) {
  17. response( $.map( data, function( item ) {
  18. var code = item.split("|");
  19. return {
  20. label: code[autoTypeNo],
  21. value: code[autoTypeNo],
  22. data : item
  23. }
  24. }));
  25. }
  26. });
  27. },
  28. autoFocus: true,
  29. minLength: 0,
  30. select: function( event, ui ) {
  31. var names = ui.item.data.split("|");
  32. id_arr = $(this).attr('id');
  33. id = id_arr.split("_");
  34. //taruh di id item no
  35. $('#itemNo_'+id[1]).val(names[0]);
  36. //taruh di id itemname
  37. $('#itemName_'+id[1]).val(names[1]);
  38. $('#StockName_'+id[1]).val(names[2]);
  39. $('#kategori_'+id[1]).val(names[5]);
  40. $('#brand_'+id[1]).val(names[4]);
  41. $('#ket_'+id[1]).val(names[7]);
  42. //old price
  43. $('#old_price_'+id[1]).val(names[3]);
  44. quantity=$('#quantity_'+id[1]).val();
  45. price=$('#price_'+id[1]).val(names[3]);
  46. $('#total_'+id[1]).val(price*quantity);
  47. calculateTotal();
  48. }
  49. });
  50. });
  51.  
  52.  
  53.  
  54.  
  55.  
  56. <!--my sql-->
  57.  
  58. $type = $_POST['type']; //it came from jquery but don't know how it coming
  59. $name = $_POST['name_startsWith']; //it came from jquery but don't know how it coming
  60. $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