M. Schaefer
2009-Mar-06 12:39 UTC
Multiplicate values of 2 textfields in a multi model form
Hi all, I tried to multiplicate two form fields in a tablerow just to inform the user and without bothering the server. I''m sure this seems to be a simple javascript problem, but all I got running was the following example: <tr class="<%= cycle(''shade1'', ''shade2'') %> itemtablerow"> <% fields_for "offer[offer_item_attributes][]", itemtablerow do |f| %> <td><%= f.text_field :pos_number, :size => 2, :index => nil %></td> <td><%= f.collection_select :study_id, Study.find(:all), :id, :index => nil %></td> <td><%= f.text_area :description, :index => nil %></td> <td><%= f.text_field :amount, :class => ''amount'', :size => 7, :index => nil %></td> <td><%= f.text_field :price, :class => ''price'', :size => 7, :index => nil %></td> <td><%= link_to_function ''product'', "alert(parseFloat($(this).up(''.itemtablerow'').down(''.price'').getValue()) * parseFloat($(this).up(''.itemtablerow'').down(''.amount'').getValue()))"%> </td> </tr> How can I multiplicate the ''price'' and the ''amount'' fields and show the product "onChange" in the tablerow? Thanks in advance, Marco -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---