title: Fire JS after functions in loop when other function is complete
body: <p>I have this function <code>function copy(){ // do some stuff }</code>, this function is triggerd by</p>
  
  <pre><code>&lt;input type="text" id="calc_inkoop_std" name="calc_inkoop_std" value="" onkeyup="copy()"&gt;
  </code></pre>
  
  <p>After this function I need to have another function triggerd, but since this is an loop I can't just simple use <code>validate(selectVeld, nr)</code></p>
  
  <p>How can I run through all lines of <code>function validate(selectVeld, nr) { // do some stuff }</code></p>
  
  <p>Complete JS</p>
  
  <pre><code>    function copy()
      {
          // Kopieer materiaalkosten
          var i, totaal = 0;
          var elems = document.getElementsByName('calc_inkoop_std_copy[]');
          var l = elems.length;
          for(i=0; i&lt;l; i++)
          {
              elems[i].value = document.getElementById('calc_inkoop_std').value;
          }
  
          validate();
      }
  
      function validate(selectVeld, nr)
      {
          // Materiaalkosten
          if(document.getElementById('calc_inkoop['+nr+'][]').value &gt; 0)
          {
              document.getElementById('calc_materiaalkost['+nr+'][]').value  = ((document.getElementById('calc_gewicht_stk['+nr+'][]').value * (document.getElementById('calc_inkoop['+nr+'][]').value / 1000)) * ((document.getElementById('calc_afval_perc['+nr+'][]').value / 100) + (1 * 1))).toFixed( 2 );
          }
          else
          {
              document.getElementById('calc_materiaalkost['+nr+'][]').value  = ((document.getElementById('calc_gewicht_stk['+nr+'][]').value * (document.getElementById('calc_inkoop_std_copy['+nr+'][]').value / 1000)) * ((document.getElementById('calc_afval_perc['+nr+'][]').value / 100) + (1 * 1))).toFixed( 2 );
          }
      }
  </code></pre>
  
  <p>The other JS is triggerd in an loop:</p>
  
  <pre><code>while($row_table_3 = mysqli_fetch_array($res_table_3)){ $y++;
  echo'
        &lt;tr&gt;
          &lt;td&gt;
              &lt;input type="number" id="calc_aantal['.$y.'][]" name="calc_aantal[]" value="" onkeyup="validate(this, '.$y.')"&gt;
          &lt;/td&gt;
        &lt;/tr&gt;';
  } echo '
  </code></pre>
  
  <p>If I am using this code only line 5 is updated of <code>validate</code>. But <code>[i]</code> should be the number of the line?</p>
  
  <pre><code>var i, totaal = 0;
  var elems = document.getElementsByName('calc_inkoop_std_copy[]');
  var l = elems.length;
  for(i=0; i&lt;l; i++)
  {
      elems[i].value = document.getElementById('calc_inkoop_std').value;
  
      validate([i], 5);
  }
  </code></pre>