Forum: Ruby on Rails Need help getting value from text_field_with_autocomplete

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D2eecb3df7da359aa6f6559fddc39945?d=identicon&s=25 Damon Hill (Guest)
on 2006-02-22 01:24
(Received via mailing list)
Good day.

I have setup of a text field with auto complete and I need to grab the
value
from that text field and pass it into a method to update a row in a
table.

Here is the view:

<tr>
        <td align="center" colspan="6"><%=
text_field_with_auto_complete(
:product, :product_code ) %></td>
    </tr>
    <tr>
        <td colspan="6" align="center"><input type="button"
id="new_product_button" value="Add New Product to PO" onClick="<%=
remote_function(:update => 'new_row', :with =>
%q('product[product_code]=$('product_product_code')'), :url => { :action
=>
'addRow' }, :position => :after) %>"</td>
</tr>

Here is the controller for addRow:

def addRow
    @product =
Product.find_by_product_code(params[:product][:product_code])
    @completeRow  = render_to_string(:partial => 'complete_row')
end

Here is the complete_row partial

<td rowspan="2" align="center"><%= text_field("purchase_order_detail",
"quantity", "size"=>5) %></td>
<td rowspan="2" align="center"><%= text_field("product", "product_code",
"size"=>30) %></td>
<td rowspan="2" align="center"><input type="text" name="product_name[#{@
product.id}]" size="30" value="<%= @product.product_name %>"></td>
<td align="center"><input type="text" name="unit_price[#{@product.id}]"
size="5", value="<%= @product.unit_price %>"></td>
<td align="center"><input type="text" name="sell_price[#{@product.id}]"
size="5"></td>
</tr>
<tr>
<td align="center"><input type="text" name="unit_weight[#{@product.id}]"
size="5", value="<%= @product.unit_weight %>"></td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>

I know that the complete_row partial works because I can access it
directly
with a valid product code and get the results I am looking for.
However, when going through the view and the auto_complete, the addRow
find
method never fires.

Any thoughts and assisstance would be greatly appreciated.

Thanks,
~damon
This topic is locked and can not be replied to.