title: Auto populate price depending on selected product
body: <p>I have a form with quantity product and price.</p>
  
  <pre><code>&lt;form action="" method="POST"&gt;
  Quantity: &lt;input type="text" name="quantity" id="quantity"&gt;
  Products: &lt;select name="product" id="product"&gt;&lt;option value="1"&gt;Product 1&lt;/option&gt;&lt;option value="2"&gt;Product 2&lt;/option&gt;&lt;/select&gt;
  Price: &lt;input type="text" name="price" id="price"&gt;
  &lt;input type="submit" value="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I want to auto populate the price from database for selected product. I tried with alert</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
      $(function() {
          $( "#product" ).autocomplete({
              source: function(request, response) {
                  $.ajax({ url: "&lt;?php echo site_url('sales/price'); ?&gt;",
                  data: { term: $("#product").val()},
                  type: "POST",
                  success: function(data){
                      alert(data);
                  }
              });
          },
          minLength: 1
          });
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>The sales/price page is returning the price (90.00 or 80.00) for the product id. I trying to pass the product selected value as post and get back the result to set value of price. Any help will be much appreciated. </p>