Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating a text field updates a table cell (per row basis)
    primarykey
    data
    text
    <p>I have a table for adding lines to an estimate to send to my clients, looking roughly like this:</p> <pre><code>&lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Qty&lt;/th&gt; &lt;th&gt;Kind&lt;/th&gt; &lt;th&gt;Description&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;th&gt;Discount&lt;/th&gt; &lt;th&gt;Tax&lt;/th&gt; &lt;th&gt;Total&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="qty[]" class="qty" /&gt;&lt;/td&gt; &lt;td&gt;&lt;!-- select field with different kinds of services --&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="desc[]" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="price[]" class="price" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="discount[]" class="discount" /&gt;&lt;/td&gt; &lt;td&gt;&lt;!-- select field with tax rates --&gt;&lt;/td&gt; &lt;td class="total"&gt;&lt;!-- here goes the total amount (qty * price - discount) --&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;span class="subtotal"&gt;&lt;!-- the total amount (all lines together) --&gt;&lt;/span&gt; </code></pre> <p>When there's a keypress event on input.qty, input.discount and input.price, the td.total needs to be updated for the total sum on each line. I have a function where I can add several table rows, hence the array of inputs.</p> <p>So what I need is when the input fields are updated, jQuery needs to update the following td.total. I tried with both, $('input.qty').keypress(function(){ $(this).next('td.total').html() }) but that didn't work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload