jQuery with php while on table tr td sum of the column for sub total
<p>i was wondering if my jquery is correct for add the td and get the total for the sub total and total.</p>

<p>my jquery is,</p>

<pre><code>$(document).ready(function(){
    var sum = 0;
    var td = $('input[name=sumof]').val();
    jQuery.each(td,function(number){
            sum += parseInt($(this).val());
        $('#total_f').val(sum);
    });
})
</code></pre>

<p>and this is my html</p>

<pre><code>&lt;div class="quotation_computation" style="margin-top:50px;"&gt;
    &lt;table cellpadding="5" cellspacing="0" width="100%"&gt;
        &lt;tr&gt;
            &lt;th&gt;#&lt;/th&gt;
            &lt;th&gt;Definition&lt;/th&gt;
            &lt;th&gt;Amount&lt;/th&gt;
            &lt;th&gt;Total&lt;/th&gt;
            &lt;th&gt;BTW&lt;/th&gt;
        &lt;/tr&gt;
        &lt;?
        $get_details = mysql_query( "SELECT * FROM jon_com_quo_computation WHERE com_code = '".$_GET['ccom']."' " ) or die ( mysql_error());

            $found_record = mysql_num_rows( $get_details );
            if ( $found_record != 0 ) {
            while( $set_det = mysql_fetch_array( $get_details ) ) {
                $total = $set_det['quo_quantity'] * $set_det['quo_amt'];
            ?&gt;
        &lt;tr&gt;
            &lt;td class="add_text"&gt;
                    &lt;?=$set_det['quo_quantity'];?&gt; x
            &lt;/td&gt;
            &lt;td class="add_text" width="250"&gt;&lt;?=$set_det['quo_definition'];?&gt;&lt;/td&gt;
            &lt;td class="sum_text"&gt;
                    &lt;?=$set_det['quo_amt'];?&gt;
                &lt;input type="hidden" name="sumof" value="&lt;?=$set_det['quo_amt'];?&gt;" /&gt;
            &lt;/td&gt;
            &lt;td class="add_text" id="total"&gt;&lt;?=$total;?&gt;&lt;/td&gt;
            &lt;td class="add_text"&gt;&lt;?=$set_det['quo_btw'];?&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;?
                }
            } else {
            ?&gt;                
        &lt;tr&gt;
            &lt;td class="add_text"&gt;#&lt;/td&gt;
            &lt;td class="add_text"&gt;Definition&lt;/td&gt;
            &lt;td class="add_text"&gt;Amount&lt;/td&gt;
            &lt;td class="add_text" id="total"&gt;Total&lt;/td&gt;
            &lt;td class="add_text"&gt;BTW&lt;/td&gt;
        &lt;/tr&gt;
        &lt;?
            }
            ?&gt;
    &lt;/table&gt;
&lt;/div&gt;

&lt;div class="sub_total_computation" style="width:200px; position:relative; left:325px;"&gt;
&lt;?
    $get_total_computation = SET_SQL( "SELECT quo_btw FROM jon_com_quo_computation WHERE com_code = '".$_GET['ccom']."' " );


    ?&gt;
    &lt;table cellpadding="5" cellspacing="0" width="100%"&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;strong&gt;Sub Total&lt;/strong&gt;&lt;/td&gt;
            &lt;td&gt;
                &lt;span id="total_f"&gt;&lt;/span&gt;
                &lt;input type="hidden" name="total_f" value="" /&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;?=$get_total_computation['quo_btw'];?&gt;&lt;/td&gt;
            &lt;td&gt;&lt;?=$btw;?&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
            &lt;td&gt;&lt;?=$btw;?&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/div&gt;
</code></pre>

<p>if you saw the <code>hidden name=sumof</code> im going to put there the answer also in the <code>td class=sum_text</code> but the answer did not appear.
Do we need to use on <code>.keyup</code> function so that the jquery will appear?
Or i just need to use the <code>PHP</code> so that it will work?</p>

<p>thank you sir.</p>
