Hi everyone and thanks for reading!
I use JavaScript to create sets of text boxes on the fly. I also have a hidden counter in a text box on the form which I also post to my PHP script. This hidden counter is how I tell PHP how many text boxes there are upon post (as PHP would have no idea if the user generated one more set, or ten more sets!).
if (isset($_POST["submit"])) {
// Bind the value of the counter to a variable.
$counter = $_POST["counter"];
echo "<p>There are <strong>" . $counter . "</strong> sets of text boxes.</p>\r\n";
}
These text boxes are named reference1, quantity1, details1 .... reference2, quantity2, details2 and so on. So by using something like the following, I can make PHP pick up the values:
for ($i=0; $i <= $counter; $i++) {
echo "<ul>\r\n";
echo "<li>";
echo $_POST["reference$i"] . " ";
echo $_POST["quantity$i"] . " ";
echo $_POST["details$i"] . " ";
echo "</li>\r\n";
echo "</ul>\r\n";
}
Is there any way I can bind these to variables? What I'm wanting to do is put each of these text boxes through some validation checks i.e. is it empty and so on, then return the form with the same amount of text boxes to the user and tell them what was wrong. Hope that makes sense!
Thanks,
Anthony