want to pass parameter values in javascript in yii framework
<p>In Yii framework using html elements for displaying contents. In that want to pass the (<code>$i</code>) values on the <code>onchange</code> method and calculation done in script. Only the first value is coming always on <code>onchange</code> method. Want to get current value of (<code>$i</code>) which is looping in <code>foreach</code> loop.</p>

<pre><code>&lt;?php $i=0; foreach($sub_marks as $sub) { $i++?&gt;

  &lt;td&gt;
    &lt;?= Html::textInput('reg_cia'.$i,"",['id'=&gt;'reg_cia','style'=&gt;'width:40px']); ?&gt;
  &lt;/td&gt;
  &lt;td&gt;

    // Here the onchange method only first value is passing always 
    &lt;?= Html::textInput('reg_ese'.$i,$i,['id'=&gt;'reg_ese','tabindex'=&gt;'1','style'=&gt;'width:40px','onchange'=&gt;'js:alerts()'])?&gt;\

  &lt;/td&gt;
  &lt;td&gt;
    &lt;?= Html::textInput('reg_total'.$i,"",['id'=&gt;'reg_total','style'=&gt;'width:40px']); ?&gt;
  &lt;/td&gt;

  &lt;/tr&gt;
&lt;?php } ?&gt;
&lt;?php } ?&gt;
&lt;/table&gt;

&lt;script&gt;
  function alerts()
  {
    var a="reg_cia";
    var b="reg_ese";
    var s=document.getElementById(a).value;
    var g=document.getElementById(b).value;
    alert(s+g);
  }
  &lt;/script&gt;
</code></pre>