checkbox state checked php -
how check checkbox when toggled other checkbox?
my code looks this:
<form method="post"><input type="checkbox" name="checkall" value = "post" /> </form> <?php foreach($records $r){ if(isset($_post["checkall"]) == 'post'){ $chc = "checked = 'checked'"; } else{ $chc = ""; } } ?> <form method="post"> <input type="checkbox" name="<?php echo escape($r->id); ?>" class="check" value="post" <?php echo $chc ;?> /> </form> the code doesn't work can me please.
thanks lot!
job
... foreach($records $r){ if($_post["checkall"] == 'post') { ... isset() function tell $_post['checkall'] there or not , checks has value in or not.
if want comapare $_post['checkall'] value, have compare example above. if want both, use 2 if conditions below
... foreach($records $r) { if(isset($_post['checkall']) { if($_post["checkall"] == 'post') { ... ... } } that you. first of all, before putting codes, plan structure of page, have , visitors have do. without plan, end reaching , stuck. code have presented not recommended.
if put more codes in questions, extent.
Comments
Post a Comment