Hi all,
I have a javascript function such as this:
And my php script is like this:
This check/uncheck box does not work and I believe the problem is because i am dynamically creating an array of checkboxes called credID. BTW if anyone doesn't understand why I subtituted a funcion checkbox_tag() for an HTML tag it is because this PHP script is following the symfony framework... I just want to know about the js problem. Any way around this? Thanks.
I have a javascript function such as this:
Code:
function checkAll(checkName, exby)
{
document.write(checkName)
document.write(exby)
for (i = 0; i < checkname.length; i++)
checkname[i].checked = exby.checked? true:false
}
And my php script is like this:
Code:
<table border=0>
<tr><th colspan="2">[b]<input type="checkbox" name="all" onClick="checkAll(document.doAssignRolesForm.credID,this)">Check/Uncheck All[/b]</th><th colspan=<?php echo $numColsspan ?>>Role</th></tr>
$count = 0;
foreach($Roles as $role){ ?>
<?php if(in_array($role->getCredUnid(), $credBank)){?>
<?php if(($count % $numCols) == 0){?>
<tr>
<?php } ?>
<td><?php [b]echo checkbox_tag('credID[]', $role->getCredUnid(), true); [/b]?></td>
<td><?php echo $role->getDescription();?></td>
<?php $count++; ?>
<?php if(($count % $numCols) == 0){?>
</tr>
<?php } ?>
<?php }
else { ?>
<?php if(($count % $numCols) == 0){?>
<tr>
<?php } ?>
<td><?php echo checkbox_tag('credID[]', $role->getCredUnid(), false); ?></td>
<td><?php echo $role->getDescription(); ?></td>
<?php $count++; ?>
<?php if(($count % $numCols) == 0){?>
</tr>
<?php } ?>
<?php } ?>
<?php }
This check/uncheck box does not work and I believe the problem is because i am dynamically creating an array of checkboxes called credID. BTW if anyone doesn't understand why I subtituted a funcion checkbox_tag() for an HTML tag it is because this PHP script is following the symfony framework... I just want to know about the js problem. Any way around this? Thanks.