Hi, I am working on a PHP page where I have 5 rate, 5 qty and 5 amount fields. When I am define all the fields manually, i.e. defining each field with a separate filed name, field id then it is working. But when I have used a loop to do that for me I failed. Is it possible to create the same using loop, or do I have to do it manually?
Sample code
<tr>
<td>
<input name="rate1" id="rate1" type="text" >
</td>
<td>
<input name="qty1" id="qty1" type="text" >
</td>
<td>
<input name="amt1" id="amt1" type="text" readonly="readonly">
</td>
</tr>
<tr>
<td>
<input name="rate2" id="rate2" type="text" onkeyup="integeronly(this)" >
</td>
<td>
<input name="qty2" id="qty2" type="text" onkeyup="integeronly(this)" >
</td>
<td>
<input name="amt2" id="amt2" type="text" readonly="readonly">
</td>
</tr>
Can't it be written like this -
<?php
$i=0;
while ($i <= 10)
{
?>
<tr>
<td>
<input name="rate$i" id="rate$i" type="text" onkeyup="integeronly(this)" >
</td>
<td>
<input name="qty$i" id="qty$i" type="text" onkeyup="integeronly(this)" >
</td>
<td>
<input name="amt$i" id="amt$i" type="text" readonly="readonly">
</td>
</tr>
<?php
$i++;
}
?>