Customizing autocomplete to update more than one value upon


#1

Good day.

Currently I have a system that will successfully add a row to a table.
Each row in this table will represent a new product being added to a
purchase order.
The user can enter a quantity and then select a product code.
The product code is the auto_complete field. This field works.
However, once the user selects a product code then the values for the
product description, buy price, and unit weight should be updated
automatically.
To try and achieve this I have implemented the following:

view:

<%= text_field_with_auto_complete( :product, :product_code, {}, { :updateElement => 'function(selectedElement){ alert("Element Selected: " + selectedElement.id);}' }) %>

controller:
def auto_complete_for_product_product_code
auto_complete_responder_for_products params[:product][:product_code]
end

private
def auto_complete_responder_for_products(value)
@products = Product.find(:all, :conditions => [‘product_code LIKE
?’,
‘%’ + params[:product][:product_code] + ‘%’] )
render :partial => ‘podetails_product’
end

partial:

    <% for @product in @products do %>
  • <%= @ product.product_code %>
  • <% end %>

The log shows the following when attempting to enter a product code:
Processing
PurchaseOrderDetailController#auto_complete_for_product_product_code
(for
127.0.0.1 at 2006-01-10 09:19:52) [POST]
Parameters: {“product”=>{“product_code”=>“5”},
“action”=>“auto_complete_for_product_product_code”,
“controller”=>“purchase_order_detail”}
e[4;36;1mProduct Load (0.078000)e[0m e[0;1mSELECT * FROM products
WHERE
(product_code LIKE ‘%5%’) e[0m
e[4;35;1mProduct Columns (0.000000)e[0m e[0mSHOW FIELDS FROM
productse[0m
Rendered purchase_order_detail/_podetails_product (0.12500)
Completed in 0.28100 (3 reqs/sec) | Rendering: 0.12500 (44%) | DB:
0.07800(27%) | 200 OK [
http://localhost/purchase_order_detail/auto_complete_for_product_product_code
]

The result after a product code is chosen is nothing.
Nothing happens in the view and nothing happens in the log file.

Thoughts?
~damon