So basically i want to check all the check-boxes within a html div if the "parent checkbox" for that div is checked. I'm new at javascript/php/html. can anyone provide an useful explanatory example?
Here's my code:
<form>
<?php
while(list($k, $v)=each($Aff))
{
if ($k == 0)
{
array_push($parentAff, substr($v, 0, 2));
$substring = $v;
echo ('<div id ="Div'.$v.'">');
}
if ((substr($substring, 0, 2) != substr($v, 0, 2)) && (strlen($substring) != 1))
{
echo ('</div>');
echo ('<div id ="'.$v.'">');
array_push($parentAff, substr($v, 0, 2));
$counter++;
$substring = $v;
echo "<hr>";
}
echo ('<input type="checkbox" name="Aff[]" id="'.$v.'" value="'.$v.'" /><label for="text'.$k.'">'.$v.'</label>');
$substring = $v;
}
echo ('</div>');
?>
</form>
The number of checkboxes within a div depend on what data comes out of the database to the array Aff[]. the parent checkbox for each div would be the one in the parentAff array wich is identified by the div id.
Aucun commentaire:
Enregistrer un commentaire