title: How to get the product of two field into another field in each button click
body: <p>I have 3 textboxes.product of two  textboxes are get into another textbox automatically.the fields are quantity and per/unit.then these two is multiplied into the field amount in each click.But the problm is i got the product in first click only..</p>
  
  <p><strong>js</strong></p>
  
  <pre><code>                var new_string='&lt;div class="form-group" id="exp_'+unqid+'"&gt;'
                  +'&lt;label for="exampleInputPassword1"&gt;'+name+'&lt;/label&gt; &lt;/br&gt;'
                   +'&lt;input name="quantity_'+unqid+'" type="text" id="quantity" style="margin-right:20px;"  class="form-con"  placeholder="Quantity" required&gt;' 
                  +'&lt;input name="perunit_'+unqid+'" type="text" id="perunit" style="margin-right:20px;" onchange="getTotalAmount('+unqid+')" class="form-con"  placeholder="Per/unit" required&gt;' 
                  +'&lt;input name="amount_'+unqid+'" type="text" id="amount"   class="form-con" placeholder="Amount" required&gt;&lt;/div&gt;';
                   $("#create").append(new_string);
  </code></pre>
  
  <p><strong>called function</strong></p>
  
  <pre><code>     function getTotalAmount(unqid)
          {
             alert(unqid);
  
              var q = document.getElementById("quantity").value;
              //alert(q);
              var p = document.getElementById("perunit").value;
             // alert(p);
              if(q!='' &amp;&amp; p!='')
                  {
                  var total = p * q;
                  // alert(total);
                  document.getElementById("amount").value = total; 
              }
          }
  </code></pre>