My code was escaped it should like this:
Hopefully this will work. 🙂
Hello:
I have a form that the input fields are generated dynamically on a grid such as:
<input type="text" name="quantity_1_22">
<input type="text" name="quantity_2_22">
<input type="text" name="quantity_3_22">
<input type="text" name="quantity_4_22">
<input type="text" name="quantity_5_22">
<input type="text" name="quantity_1_23">
and so on and so forth.
On the server side when the form is
submitted I want to parse the form elements and loop through them to see which ones have been filled in, I am using the following code for this:
//Assign the min & max x & y values.
$xrangeBegin = 1;
$xrangeEnd = 5;
$yrangeBegin = 22;
$yrangeEnd = 24;
for ($j = $xrangeBegin; $j <= $xrangeEnd; $j++) {
for ($k = $yrangeBegin; $k <= $yrangeEnd; $k++) {
$quantity = "\$quantity" . "" . $j . "" . $k;
if (isset($quantity)) {
echo "$quantity<br>";
}
}
}
The problem that I have is the assigning of the $quantity variable. The variable is assigned as a string: $quantity_1_22
as it goes through the loop it changes to:
$quantity_1_23
$quantity_1_24
ect..
My idea is that I want to parse and go through each form element to check and see if there was a value entered for that field, if so print it. What am I doing wrong? And how could I parse this the right way for each of the input values?
Thanks,
Troy