james_cwy
12-07-2003, 08:39 PM
I know that say if we have 3 input boxes.
<input type="text".... name"name1">
<input type="text".... name"name2">
<input type="text".... name"name3">
To check the fields, it is easy as we can just hardcode it.
if document.form.name1.value == " ", etc...
But if I have something like this to generate number of input boxes based on user input.
User enters 3 to generate number of input boxes.Pass this 3 to the next form, then use a for loop to do the input box rather than typing one by one:
$num=$_POST['number'];//that is 3
for ($i=1;$i<=$num;$i++)
{
<td align=center><input type="text" name="name<?php echo $i;?>"></td>
}
The end result will also be:
<input type="text".... name"name1">
<input type="text".... name"name2">
<input type="text".... name"name3">
My question here: How can we check the input boxes when they are generated using for loop?
I hope you get what I mean. I am new to this and really do not know how to go about it.
Hope someone can provide some guidance.
<input type="text".... name"name1">
<input type="text".... name"name2">
<input type="text".... name"name3">
To check the fields, it is easy as we can just hardcode it.
if document.form.name1.value == " ", etc...
But if I have something like this to generate number of input boxes based on user input.
User enters 3 to generate number of input boxes.Pass this 3 to the next form, then use a for loop to do the input box rather than typing one by one:
$num=$_POST['number'];//that is 3
for ($i=1;$i<=$num;$i++)
{
<td align=center><input type="text" name="name<?php echo $i;?>"></td>
}
The end result will also be:
<input type="text".... name"name1">
<input type="text".... name"name2">
<input type="text".... name"name3">
My question here: How can we check the input boxes when they are generated using for loop?
I hope you get what I mean. I am new to this and really do not know how to go about it.
Hope someone can provide some guidance.