Checkbox, elements in a array
Halo,
in a formula I have a list with checkbox, if the user click on one box, the box value shut be put it in a array.
If the user click again on the same box, the value shut be remove from the array.
Here my php part:
-
foreach( $ob as $key => $value){
?>
<tr>
<td align="center" >
<input type="checkbox" name="box4_<?php echo $value->id;?>" id="box4_<?php echo $key;?>" value="<?php echo $value->id;?>" onClick="takeBox( '<?php echo $value->id;?>' );">
</td>
</tr>
<?php
}
Here my JS part with jQuery, I use the version 1.2.6:
-
arrMyValues = new Array();
var arrMyValueslength = arrMyValues.length;
function takeBox( newID )
{
var bExist = false;
$.each(arrMyValues, function(n, value){
if( value == newID) {
bExist = true;
}
});
if( bExist == false ) {
arrMyValueslength = ( arrMyValueslength +1 );
arrMyValues[ arrMyValueslength ] = newID;
}
}
What I make is not only bad
Have somebody a idea who could it work?
Greeting
reg56