PCHomepage
Programmer
On a form using simple checkboxes that submit as an array SubData[], I am trying to convert the receiving end back into variables that can be used but can't quite get the syntax. The values are those in the globals but without the "Sub" and I am trying to prepend "Sub" to the results. What I have looks like it should work but it doesn't so clearly I've done somethign wrong. How can this be done?
In case the question is more easily answered with the form, here it is:
. . . and I am testing it by echoing the variables to the screen:
Code:
global $SubGreenR;
global $SubRed;
global $SubBlue;
global $SubGreenB;
global $SubRGr;
global $SubBGb;
global $SubTotal;
if (isset($_POST['SubData'])):
$SubData = $_POST['SubData'];
foreach ($SubData as $key => $val):
$SybData[$key][0] = ${"Sub".$val};
endforeach;
endif;
In case the question is more easily answered with the form, here it is:
Code:
<form class="SubForm" name="SubForm" method="POST" action="testcheckbox.php">
GreenR:<input type="checkbox" name="SubData[]" id="SubData[]" value="GreenR">
Red:<input type="checkbox" name="SubData[]" id="SubData[]" value="Red">
Blue:<input type="checkbox" name="SubData[]" id="SubData[]" value="Blue">
GreenB:<input type="checkbox" name="SubData[]" id="SubData[]" value="GreenB">
RGr:<input type="checkbox" name="SubData[]" id="SubData[]" value="RGr">
BGb:<input type="checkbox" name="SubData[]" id="SubData[]" value="BGb">
Total:<input type="checkbox" name="SubData[]" id="SubData[]" value="Total">
<input type="submit" value="FormTest" name="SubmitNew">
</form>
. . . and I am testing it by echoing the variables to the screen:
Code:
echo "<p><strong>Variables assigned:</strong>\n<p>";
echo "<p>GreenR: ".$SubGreenR."\n<br>";
echo "Red: ".$SubRed."\n<br>";
echo "Blue: ".$SubBlue."\n<br>";
echo "GreenB: ".$SubGreenB."\n<br>";
echo "RGr: ".$SubRGr."\n<br>";
echo "BGb: ".$SubBGb."\n<br>";
echo "Total: ".$SubTotal."\n<br>";