Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $(function(){
- $("#get_names_product").autocomplete({
- source: "<?php echo site_url('inventory/get_price'); ?>" // path to the get_product_price method
- });
- });
- </script>
- <form name="frmOne" id="newBatch" class="form-horizontal" action="" method="post">
- <div class="form-group">
- <label for="customerName" style="color:#3fa9f5;" class="col-sm-3 control-label">Product Name</label>
- <div class="col-sm-8">
- <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">
- </div>
- </div>
- <div class="form-group">
- <label for="cost" style="color:#3fa9f5;" class="col-sm-3 control-label">Unit</label>
- <div class="col-sm-8">
- <input type="text" value="<?php echo isset($post)?$post->unit:''; ?>" class="form-control" name="systemProduct[cost]" placeholder="Enter Product Cost ">
- </div>
- </div>
- </form>
- function get_product_names()
- {
- $this->load->model('productModel', 'product');
- if (isset($_GET['term'])) {
- $q = strtolower($_GET['term']);
- $this->product->get_name_product($q);
- }
- }
- function get_name_product($q)
- {
- $q = $this->db->query("SELECT distinct `product_name` FROM `product` where `deleteProduct` = '0' and product_name LIKE '%$q%'");
- if ($q->num_rows() > 0) {
- foreach ($q->result_array() as $row) {
- $row_set[] = htmlentities(stripslashes($row['product_name'])); //build an array
- }
- echo json_encode($row_set); //format the array into json data
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement