fetching values and calculating using jQuery
<p>i have some input fields</p>

<pre><code>&lt;input type="text" name="quantity[]" class="est_quantity" placeholder="quantity"/&gt;
&lt;input type="text" name="quantity[]" class="est_quantity" placeholder="quantity"/&gt;
&lt;input type="text" name="quantity[]" class="est_quantity" placeholder="quantity"/&gt;

&lt;input type="text" name="cost[]" class="est_cost" placeholder="cost"/&gt;
&lt;input type="text" name="cost[]" class="est_cost" placeholder="cost"/&gt;
&lt;input type="text" name="cost[]" class="est_cost" placeholder="cost"/&gt;
</code></pre>

<p>i need to perform some calculations.</p>

<pre><code>//Calculate total Quantity, this is how i do it.
$('.est_quantity').live('keyup', function(){
    var val = 0;
    $('.est_quantity').each(function() {
        if($(this).val().length &amp;&amp; $(this).val() != '') {
            val += Number($(this).val());
            $('.est_total_quantity').html(val);
        }
    });
});
</code></pre>

<p>the above code works fine, since total quantity is the sum of all <code>quantity[]</code> however calculating the total cost is little different. since the calculation goes like this.</p>

<pre><code>total cost = total_quantity * cost
//for each field or row.
</code></pre>

<p>while calculating the cost i want the value to be multiplied by it's corresponding quantity field.</p>

<p>something like</p>

<pre><code>var cost = $('.est_quantity').val * $('.est_cost').val();
</code></pre>

<p>i tried doing it this way</p>

<pre><code>$('.est_cost').live('keyup', function(){
    var val = 0.00;
    $('.est_cost').each(function() {
        if($(this).val().length &amp;&amp; $(this).val() != '') {
            var cost = $(this).val() * $('.est_quantity').val();
            val += parseFloat(cost);
            $('.est_total_cost').html(val.toFixed(2));
        }
    });
});
</code></pre>

<p>the above code fetch proper calculations for only first row, for rest it fetches some weird value.</p>

<p>how do i go with the code for proper calculations?</p>

<p>P.S: initially there is one row of input fields which includes quantity and cost input fields, the rest input fields are dynamically added upon click event.</p>

<p>thank you</p>
