Dynamically created checkbox
Posted: Thu Dec 07, 2006 3:10 am
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?
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?