my problem is accessing the checkboxes on the form that is created ... I'm using a foreach to create a html "cell" and need to access the checkbox within the cell ...
i.e.
Code: Select all
// this is created from a db stored in a separate file
global $ItemsForSale;
$ItemsForSale = array(
"stuff" => array ( "25.95" , 0 ),
"more stuff" => array ( 12.01, 0),
"etc" => array ( "TBA", 1) );Code: Select all
function makeTable( $words, $cost ) {
echo '<TR>
<TD>' . $words . '</TD> // this will unique
<TD> $' . $cost . '</TD>
<TD <INPUT TYPE="CHECKBOX" NAME="' . $words . '"></TD> // the problem could be here
</TR>';
}// this is how it uses maketable
Code: Select all
foreach ($ItemsForSale as $key => $value) {
makeTable($key, $valueї0] );
}// **** the problem is here (I think) *****
// accessing the value of the checkbox created with maketable
// what I'm tring to do here is loop through the origonal array to get the names of the checkboxes to see if it is checked ... if so, add only that data line ( of the origonal array to another called seleced items )
Code: Select all
$SelectedItems = array();
foreach ($ItemsForSale as $key=>$value) {
// use the item name to call the checkbox object by referance
// **** this next line would need to understood as if ( stuff.value ) where
// stuff is the name of the checkbox from above
if ( $key.value ) { // if this Item was selected
$SelectedItemsї$key] = $valueї0];
// if $Item is a number ( not free ) tally
if ( is_int($value) ){ $Total += $Value; }
} // else do nothing
}if there there is a better to do this please let me know ... I run into similar problems like this in other languages ... not sure if it's a bad way to do things or if it's just lack of skill.
thanks guys