thenetduck
August 11th, 2008, 04:34 AM
Hi
I am creating an app in which I can add cards to piles. When you create a "card" you can add it to multiple piles (a list of cards). I would like to use a checkbox to handle this, however I need to be able to get data about multiple piles checked.
if that makes sense...
My question is, how can I create multiple checkboxes with data that changes and then receive that data when submitting the the form? As of now, this is what my displayPiles() function looks like.
function displayPiles()
{
// Create a new user object.
$user = new user();
$piles = $user->getPiles();
$pile_list .= '<tr>';
$i = 1; // ignore this, it's just an index to keep track of number of piles in a row.
$row_display = 5; // this is the number of piles per row.
for ($j=0; $j<sizeof($piles); $j++)
{
if($i%$row_display == 0){$pile_list .='<tr>';}
$pile_id = $piles[$j][0];
$pile_name = $piles[$j][1];
$pile_list .=
'<td valign=top align=center>
<input type="checkbox" name="piles" value= ' . ' " ' . $pile_id. ' " ' . ' /><br />' .
$pile_name . '<br /> ' . $user->getNumberOfCards($pile_id) . ' cards in pile' .
'</td>' ;
if($i%$row_display == 0){$pile_list .='</tr>';}
}
$pile_list .= '</tr>';
return $pile_list;
}
// Call the function to display the piles.
echo displayPiles();
What is the proper way to receive/process the $_POST['piles'] name that is generated?
Thanks
The Net Duck
I am creating an app in which I can add cards to piles. When you create a "card" you can add it to multiple piles (a list of cards). I would like to use a checkbox to handle this, however I need to be able to get data about multiple piles checked.
if that makes sense...
My question is, how can I create multiple checkboxes with data that changes and then receive that data when submitting the the form? As of now, this is what my displayPiles() function looks like.
function displayPiles()
{
// Create a new user object.
$user = new user();
$piles = $user->getPiles();
$pile_list .= '<tr>';
$i = 1; // ignore this, it's just an index to keep track of number of piles in a row.
$row_display = 5; // this is the number of piles per row.
for ($j=0; $j<sizeof($piles); $j++)
{
if($i%$row_display == 0){$pile_list .='<tr>';}
$pile_id = $piles[$j][0];
$pile_name = $piles[$j][1];
$pile_list .=
'<td valign=top align=center>
<input type="checkbox" name="piles" value= ' . ' " ' . $pile_id. ' " ' . ' /><br />' .
$pile_name . '<br /> ' . $user->getNumberOfCards($pile_id) . ' cards in pile' .
'</td>' ;
if($i%$row_display == 0){$pile_list .='</tr>';}
}
$pile_list .= '</tr>';
return $pile_list;
}
// Call the function to display the piles.
echo displayPiles();
What is the proper way to receive/process the $_POST['piles'] name that is generated?
Thanks
The Net Duck