I want to write a javascript function in order to fill the text boxes taking values from the variables from21, from22, ....
The text boxes whose values are not available (say from11, from12,... etc) should remain blank. Actually if add value='$from21', then the boxes will be filled onload. But I want the boxes to remain empty onload. These should be filled only on button click.
<?php
for ($rn = 2; $rn <= 4; ++$rn) {
for ($slot = 1; $slot <= 5; ++$slot) {
${"from" . $rn . $slot} = $slot + $rn;
${"no" . $rn . $slot} = $slot - $rn;
}
}
?>
<html>
<script type="text/javascript">
function fun()
{
}
</script>
</html>
<?php
echo "<body>
<input type='text' id='from11'/> <input type='text' id='no11'/> <br/>
<input type='text' id='from12'/> <input type='text' id='no12'/> <br/>
<input type='text' id='from13'/> <input type='text' id='no13'/> <br/>
<input type='text' id='from14'/> <input type='text' id='no14'/> <br/>
<input type='text' id='from15'/> <input type='text' id='no15'/> <br/>
<input type='text' id='from16'/> <input type='text' id='no16'/> <br/>
<input type='text' id='from31'/> <input type='text' id='no31'/> <br/>
<input type='text' id='from32'/> <input type='text' id='no32'/> <br/>
<input type='text' id='from33'/> <input type='text' id='no33'/> <br/>
<input type='text' id='from34'/> <input type='text' id='no34'/> <br/>
<input type='text' id='from35'/> <input type='text' id='no35'/> <br/>
<input type='text' id='from36'/> <input type='text' id='no36'/> <br/>
";
?>
<html>
<input type="button" value="Fill" id="fun1" onclick="fun( )"/>
</html>
<?php
echo "</body>";
?>