Im having a set of checkboxes in a page created dynamically
Code:
in form page
<input name="item_chk[<?php echo $i; ?>]" type="checkbox" id="item_chk[<?php echo $i; ?>]" value="<?php echo $product_ID; ?>">
This creates checkboxes item_chk[0],item_chk[1] etc.
While submitting in the processing page i have to retrieve the value of the checkbox which is checked
Im trying like this:
i have the total no of check boxes created
Code in processing page
$item_chk =$_POST["item_chk"];
$i=0;
while($i<total)
{
if($item_chk[$i]!="")
{
echo $item_chk[$i];
}
$i++;
Is this correct or how to get the data?
Dynamically created checkbox
Moderator: General Moderators
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
This works...
Code: Select all
$i=0;
while($i<total)
{
$element = "item_chk$i";
if(!empty($_POST[$element]))
{
echo $_POST[$element];
}
$i++;
}