I've problem to loop textfield
with event onfocus()
and onblur()
. In single row, that event can running correctly, but if I try to make two rows with for
looping in the textfield, that event on the textfield
can't running.
I need solution about this problem, thanks
<script type="text/javascript">
function startCalc() {
interval=setInterval("calc()",1);
}
function calc() {
var obj=document.hitung;
var one=obj.sks.value;
if(one == 2)
{ var hsks = 14; }
else if(one == 4)
{ var hsks = 28; }
else
{ var hsks = 0; }
obj.n_pertemuan.value=(hsks);
}
function stopCalc() {
clearInterval(interval);
}
</script>
<center>
<form name="hitung">
<?php
for($x = 1; $x <= 2; $x++)
{
?>
<table width="205" border="1" cellspacing="0" cellpadding="2">
<tr>
<td height="44" colspan="2" align="center">Js Coba</td>
</tr>
<tr>
<td width="84" align="center">SKS</td>
<td width="113" align="center">PERTEMUAN</td>
</tr>
<tr>
<td align="center"><input name="sks" type="text" onFocus="startCalc();" onBlur="stopCalc();" size="5"/></td>
<td align="center"><input name="n_pertemuan" type="text" size="5" ></td>
</tr>
</table>
<?php } ?>
</form>
</center>