Hi everyone,
I opted to do this as checkboxes vs a select list because I could not come up with a 'working' option that did not fall apart at some point [hopefully, this avenue will not either] so please bear with me.
I have a series of checkboxes that are dynamically created from a previous form, and are named Class, and contain all the possible 'classes' (88 total subjects taught, and I need to let them choose multiple classes, IE, thats why I opted for checkboxes) that a teacher may have used for each of the video they chose on the previous form.
So on this form, I will give this example. (Here I will show 2 videos selected from the previous form, creating 2 sets of checkboxes for the 'Class' checkboxes, so for so good?
//HTML for 1st set of checkboxes
<label for=0_1 style='padding-right:3px;display:block;'><input name='Class[0]' value='1' type='checkbox' id=0_1 onclick='highlight_div(this);'>Accounting</label>
<label for=0_2 style='padding-right:3px;display:block;'><input name='Class[0]' value='2' type='checkbox' id=0_2 onclick='highlight_div(this);'>Agriculture</label>
//etc
//HTML for 2nd set of checkboxes
<label for=1_1 style='padding-right:3px;display:block;'><input name='Class[1]' value='1' type='checkbox' id=1_1 onclick='highlight_div(this);'>Accounting</label>
<label for=1_2 style='padding-right:3px;display:block;'><input name='Class[1]' value='2' type='checkbox' id=1_2 onclick='highlight_div(this);'>Agriculture</label>
And in my form (page 2) I build the loops for each video, nesting the required elements, including this Class loop.
$zz=1;
$xx=1;
foreach($_SESSION['products'] as $key => $value)
{
// build the other elements of the form -- working fine
//---------- make a dummy array for the Class loop to use as Rating[x] names for checkbox array -----//
$Rate = array();
$Rate[$zz] = "Class[" . $key . "]"; //for the Class loop - check box array names
$zz++;
//------------------------------------------------------------------------------------//
foreach($Class_array as $key1=> $value)
{
echo '<label for=' . $xx . '_' . $key1 . ' style=\'padding-right:3px;display:block;\'><input name=\'' . $Rate[$xx] . '\' value=\'' . $key1 . '\' type=\'checkbox\' id=' . $xx . '_' . $key1 . ' onclick=\'highlight_div(this);\'>' . $value . '</label>';
}
$xx++;
}
But this will not give me a multidimensional array.
And I believe I need to change this...
echo '<label for=' . $xx . '_' . $key1 . ' style=\'padding-right:3px;display:block;\'><input name=\'' . $Rate[$xx][$key] . '\' value=\'' . $key1 . '\' type=\'checkbox\' id=' . $xx . '_' . $key1 . ' onclick=\'highlight_div(this);\'>' . $value . '</label>';
but that doesnt give me a nested array in the first array either.
I am not an array 'guru', I am missing that gene.
I would appreciate anyone with that gene's help.
Thanks,
Don