i have written code like this to select all the check boxes in the fetched data

```
 <input type="checkbox" name="select-all" id="select-all" />
    <?php
    while ($row = mysql_fetch_array($users)) {
?> 
<tr>
 <td><span><?php echo $row["id"] ?></span></td>
<td><span><?php echo $row["emailid"] ?></span></td>
<td><span class="wrapper"><input type="checkbox" name="sendmsg[]"  value="<?php echo $row["emailid"] ?>"/></span></td>
</tr>
 <?php } ?>

```

i have written java script like this 

```
  $('#select-all').click(function(event) {   
    if(this.checked) {
    // Iterate each checkbox
    $('#sendmsg[]').each(function() {
        this.checked = true;                        
       });
        }
      });

```

how to write corect script to get all the check boxes selected