The problem is that you end up with several hidden fields with the same name (see below)
Code:
<input type='hidden' name='hiddencolor' value='$color'>
<input type='hidden' name='hiddencolor' value='$color'>
<input type='hidden' name='hiddencolor' value='$color'>
<input type='hidden' name='hiddencolor' value='$color'>
<input type='hidden' name='hiddencolor' value='$color'>
<input type='hidden' name='hiddencolor' value='$color'>
<input type='hidden' name='hiddencolor' value='$color'>
Each time you create a new one, it overwrites the previous. To explain it differently, imagine the confusion if you walked into a room filled with young mothers and their children and simply yelled the word 'Mom'. No one would know what to do. HTML would have the same issue if it did not take just the last value to pass on.
To resolve your issue, there are a couple options available.
First, create and array of values. You can do this by adding brackets to the end of the name:
Code:
<input type='hidden' name='hiddencolor[]' value='$color'>
<input type='hidden' name='hiddencolor[]' value='$color'>
<input type='hidden' name='hiddencolor[]' value='$color'>
<input type='hidden' name='hiddencolor[]' value='$color'>
<input type='hidden' name='hiddencolor[]' value='$color'>
<input type='hidden' name='hiddencolor[]' value='$color'>
<input type='hidden' name='hiddencolor[]' value='$color'>
Second, you can create a unique value for the field name by tacking a number on to the end. (The syntax may not be completely accurate as I am primarily a PHP programmer, but the principle is the same)
Code:
$x=1;
@color = param('color');
foreach $color (@color) {
print "<input type='hidden' name='hiddencolor$x' value='$color'>";
$x++;
}