Note that there are some explanatory texts on larger screens.

plurals
  1. POcalculating multi inputs (jquery)
    text
    copied!<p>In my website I have an option to add (multiple times) an input with a button, using this code,</p> <pre><code>$("#add_new_detail").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" name="det['+i+'][details]" /&gt; &lt;/td&gt;&lt;td&gt; &lt;input type="text" name="det['+i+'][amount]" value="0" /&gt; &lt;/td&gt;&lt;td&gt; &lt;input type="text" name="det['+i+'][price_real]" value="0" /&gt; &lt;/td&gt;&lt;td&gt; &lt;input type="text" name="det['+i+'][price_user]" value="0" /&gt; &lt;/td&gt;&lt;td&gt; &lt;input type="text" name="det['+i+'][total_price]" value="0" DISABLED /&gt; &lt;/td&gt;&lt;td&gt; &lt;input type="text" name="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; '); i++; }); </code></pre> <p>Now, every time I click the button it really creates a new line of inputs. That is working perfect. Now I'm trying to calculate between the inputs, I'm trying to enter a number into </p> <blockquote> <p>det['+i+'][amount] </p> </blockquote> <p>and to double it with (math)</p> <blockquote> <p>det['+i+'][price_real]</p> </blockquote> <p>and to post the result in</p> <blockquote> <p>det['+i+'][total_price]</p> </blockquote> <p>now I have no idea how can I interact with these specific fields(which getting created by the button click) - every line has it own amount,price_real,total_price ... how can I make this calculate with onKeyUp ? if someone can give me an idea how am I moving on from this point I'll be grateful.</p> <p>thanks :)</p>
 

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