hi people
I don’t know much about ajax – jquery. And right now I need to use some functionality with them.
In a form (sales model) I have the following code:
<div>
<%= f.label :product_id, "Product" %>
<%= f.collection_select( :product_id, Product.all, :id, :name, options={} ) %>
</div>
<div>
<%= f.label :price, "Price" %>
<%= f.text_field :price %>
</div>
The idea is: when I select a “product” I want to show the price of that product automatically in the “price” text-field. I have a table where I store the price of each product.
I tried this example but didn’t work.
Hope you can help me, thanks
If you’re asking about what the jQuery code would look like, this should do the trick: