How to efficiently use jQuery to multiply columns of dynamically rendered table
<p>I'm working on a pretty big table/form that is dynamically created depending on stock availability. The table has 5 fields: Code, Prod.Name, Amount, Price and SubTotal. The user is supposed to set a number in the Amount field and then there's a jQuery script that multiplies that amount for the price to display the SubTotal. In the table, a product looks like this:</p>

<pre><code>&lt;tr&gt; 
    &lt;td&gt;Princess 01&lt;/td&gt; 
    &lt;td&gt;Conjunto corpiño y cola less &lt;strong&gt;Talle 85&lt;/strong&gt;&lt;/td&gt; 
    &lt;td&gt;&lt;input type="text" id="princess-lingerie-id-963" name="[princess-lingerie][id_963]" value=""&gt;&lt;/td&gt; 
    &lt;td&gt;$&lt;input type="text" id="price_princess-lingerie-id-963" value="99" readonly="readonly"/&gt;&lt;/td&gt; 
    &lt;td id="subTotal_princess-lingerie-id-963" name="subTotal"&gt;&lt;/td&gt; 
&lt;/tr&gt;
</code></pre>

<p>My problem is that I have many different products that belong to different product categories, so while this belongs to the "princess-lingerie" (don't laugh) category, a product from the "cosmetica" category looks like this:</p>

<pre><code>&lt;tr&gt;    
  &lt;td&gt;D02/3&lt;/td&gt; 
  &lt;td&gt;Magic Dual aroma Frutos Rojos&lt;/td&gt; 
  &lt;td&gt;&lt;input type="text" id="cosmetica-stock-id-1008" name="[cosmetica-stock][id_1008]" value=""&gt;&lt;/td&gt; 
  &lt;td&gt;$&lt;input type="text" id="price_cosmetica-stock-id-1008" value="26" readonly="readonly"/&gt;&lt;/td&gt; 
</code></pre>

<p>
        </p>

<p>I have actually already created the little bit of logic which would work for only one field, but I don't know how to extend it to the whole table. Could anyone give me a hand with it? ...I'm a little bit overwhelmed and don't know where to start right now.</p>

<pre><code>$(document).ready(function(){
$("#princess-lingerie-id-963").keyup(function() {
    var howMany = parseInt($("#princess-lingerie-id-963").val());
    var subTotal = parseInt($("#price_princess-lingerie-id-963").val()) * howMany;
    //assign subTotal to the td
    $("#subTotal_princess-lingerie-id-963").html(subTotal);
});
});
</code></pre>
