# Multiplicate values of 2 textfields in a multi model form

**URL:** <https://www.ruby-forum.com/t/multiplicate-values-of-2-textfields-in-a-multi-model-form/162176>\
**Category:** Rails\
**Created:** [March 6, 2009, 1:39pm UTC](https://www.ruby-forum.com/t/multiplicate-values-of-2-textfields-in-a-multi-model-form/162176 "2009-03-06T13:39:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![geek001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@geek001](https://www.ruby-forum.com/u/geek001)\
**Post date:** [March 6, 2009, 1:39pm UTC](https://www.ruby-forum.com/t/multiplicate-values-of-2-textfields-in-a-multi-model-form/162176/1 "2009-03-06T13:39:43Z")

</div>

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:

\<% fields\_for "offer[offer\_item\_attributes][]", itemtablerow do |f| %\> \<%= f.text\_field :pos\_number, :size =\> 2, :index =\> nil %\> \<%= f.collection\_select :study\_id, Study.find(:all), :id, :index =\> nil %\> \<%= f.text\_area :description, :index =\> nil %\> \<%= f.text\_field :amount, :class =\> 'amount', :size =\> 7, :index =\> nil %\> \<%= f.text\_field :price, :class =\> 'price', :size =\> 7, :index =\> nil %\> \<%= link\_to\_function 'product', "alert(parseFloat($(this).up('.itemtablerow').down('.price').getValue()) \* parseFloat($(this).up('.itemtablerow').down('.amount').getValue()))"%\> 

How can I multiplicate the ‘price’ and the ‘amount’ fields and show the  
product “onChange” in the tablerow?

Thanks in advance,  
Marco
