Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here you go... I have modified the <code>name</code> attribute to <code>id</code>. Also used <code>_</code> instead of <code>[</code>.</p> <p><strong><a href="http://jsfiddle.net/6rM42/" rel="nofollow">Live Demo</a></strong></p> <p>Whenever you change <code>amount</code> or <code>price_real</code>, the corresponding <code>total_price</code> will change <code>(total_price = amount * price_real)</code>.</p> <p><strong>jQuery</strong></p> <pre><code>$("#add_new_detail").on("click", function() { $("#det_add_area").append('&lt;div id="no_'+i+'"&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt; '+i+' &lt;/td&gt;&lt;td&gt; \ &lt;input type="text" id="det_'+i+'_details" /&gt; &lt;/td&gt;&lt;td&gt; \ &lt;input type="text" id="det_'+i+'_amount" value="0" /&gt; &lt;/td&gt;&lt;td&gt; \ &lt;input type="text" id="det_'+i+'_price_real" value="0" /&gt; &lt;/td&gt;&lt;td&gt; \ &lt;input type="text" id="det_'+i+'_price_user" value="0" /&gt; &lt;/td&gt;&lt;td&gt; \ &lt;input type="text" id="det_'+i+'_total_price" value="0" DISABLED /&gt; \ &lt;/td&gt;&lt;td&gt; &lt;input type="text" id="det_'+i+'_total_price_for_user" value="0" DISABLED /&gt; &lt;/td&gt;&lt;td&gt;\ &lt;div class="delete_line" onClick="re(\'no_'+i+'\')"&gt; delete &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;\ '); $("#det_" + i + "_amount").on("change", function() { calculate(this); }); $("#det_" + i + "_price_real").on("change", function() { calculate(this); }); i++; }); function calculate(e) { j = $(e).attr('id').split("_")[1] total = $("#det_" + j + "_amount").val() * $("#det_" + j + "_price_real").val(); $("#det_" + j + "_total_price").val(total); } </code></pre>
    singulars
    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.
 

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