Advertisement
Guest User

Untitled

a guest
May 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(function(){
  3. $("#get_names_product").autocomplete({
  4. source: "<?php echo site_url('inventory/get_price'); ?>" // path to the get_product_price method
  5. });
  6. });
  7. </script>
  8.  
  9. <form name="frmOne" id="newBatch" class="form-horizontal" action="" method="post">
  10.  
  11. <div class="form-group">
  12. <label for="customerName" style="color:#3fa9f5;" class="col-sm-3 control-label">Product Name</label>
  13. <div class="col-sm-8">
  14. <input type="text" value="<?php echo isset($post)?$post->product_name:''; ?>" class="form-control" name="systemProduct[product_name]" id="get_names_product" placeholder="Enter Product Name">
  15. </div>
  16. </div>
  17.  
  18. <div class="form-group">
  19. <label for="cost" style="color:#3fa9f5;" class="col-sm-3 control-label">Unit</label>
  20. <div class="col-sm-8">
  21. <input type="text" value="<?php echo isset($post)?$post->unit:''; ?>" class="form-control" name="systemProduct[cost]" placeholder="Enter Product Cost ">
  22. </div>
  23. </div>
  24. </form>
  25.  
  26. function get_product_names()
  27. {
  28. $this->load->model('productModel', 'product');
  29. if (isset($_GET['term'])) {
  30. $q = strtolower($_GET['term']);
  31. $this->product->get_name_product($q);
  32. }
  33. }
  34.  
  35. function get_name_product($q)
  36. {
  37. $q = $this->db->query("SELECT distinct `product_name` FROM `product` where `deleteProduct` = '0' and product_name LIKE '%$q%'");
  38. if ($q->num_rows() > 0) {
  39. foreach ($q->result_array() as $row) {
  40. $row_set[] = htmlentities(stripslashes($row['product_name'])); //build an array
  41. }
  42. echo json_encode($row_set); //format the array into json data
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement