0
I have the following Java code:
<script type='text/javascript'>
function Calc(){
var qnt = document.getElementById('qnt_saida').value;
var vlr = document.getElementById('vl_unt_org').value;
var tl = (qnt*1) * (vlr*1);
document.getElementById('vl_fob').value = tl;
}
</script>
It’s worked, my problem is in the FOR loop of php, the Calc() function is only called once. For this case below it should rotate twice:
<?php
for($i = 0; $i < $tl_detalhe; $i++){
print "
<tr>
<td> <input class='input' id='qnt_saida' name='qnt_saida' type='text' value='".number_format($_SESSION['detalhe'][$i]->QUANTIDADE,5,",",".")."' onBlur='Calc()' /></td>
<td> <input class='input' id='vl_unt_org' name='vl_unt_org' value='".number_format($_SESSION['detalhe'][$i]->VL_UNT_ORG,7,",",".")."' readonly /> </td>
<td> <input class='input' id='vl_fob' name='vl_fob' readonly /> </td>
</tr>
";
}
?>
Could someone help me with this question? Could I pass this function inside the loop to the same be called as many times as needed?
You cannot use the same id for more than one element in HTML.
– bfavaretto