<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<script language="JavaScript">
function myscript(num1,num2,num3){
alert('k=')
alert(num1);
alert('i=')
alert(num2);
alert('m=')
alert(num3);
var pcswt= eval(num3);
alert('pcswt=')
alert(pcswt);
alert(eval('myform.txtname'+num1+','+num2+'.value'));
var name=(eval('myform.txtname'+num1+','+num2+'.value'));
eval('myform.txtaddr'+num1+','+num2+'.value = name*pcswt');
}
</script>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="myform" action="mypage.php">
<?php
for ($k=1; $k<=1; $k++){
$m=4;
for ($i=0; $i<=3; $i++){
$m=$m+$k;
echo "Enter anything please: <input type='text' onKeyUp='myscript(\"".$k."\",\"".$i."\",$m);' name='txtname".$k.",".$i."'>\n";
echo "Display anything:<input type='text' name='txtaddr".$k.",".$i."'>\n";
echo "<BR>\n";
}
}
?>
</form>
</body>
</html>
Dear coder,
In my above code, I am passing arguments to javascript using
two separate FOR LOOP. When I pass arguments using single FOR LOOP its work fine, Whereas, if i execute using
second FOR LOOP. I receive following error like:
UNDEFINED
for below command in javascript.
alert(eval('myform.txtname'+num1+','+num2+'.value'));
Can u trick u r idea in solving this bug.
Thank u.
Rgds.
junior member.