The following code gets all the values from the checked checkboxes and store them in an array:
function SaveIt(id)
{
var arrayCheckedCDs = $('input:checkbox[name="checkCD[]"]:checked').map(function () {
return this.value;
}).get();
}
Here's the html:
<form>
<table id="cdsTable">
<tbody>
<tr>
<td>Id</td>
<td>Artist</td>
<td>Album</td>
<td>Select</td>
</tr>
<tr id="cd1">
<td>1</td>
<td>Jeff Buckley</td>
<td>Grace</td>
<td><input type="checkbox" value="1|Buckley|Grace" name="checkCD[]" id="checkCD1"></td>
</tr>
<tr id="cd2">
<td>2</td>
<td>U2</td>
<td>Zooropa</td>
<td><input type="checkbox" value="2|U2|Zooropa" name="checkCD[]" id="checkCD2"></td>
</tr>
.
.
</tbody></table>
<input type="submit" onclick="javascript:SaveIt(id); return false;"value="submit">
<!-- the id in SaveIt(id) is 1 or 2 or ... I get it from my php script-->
</form>
After storing the values in arrayCheckedCDs I need to hide the selected rows and uncheck the selected checks.
The hiding is easy:
$('#cdsTable #cd'+id+'').hide();
But I don't have a clue on how to uncheck the selected checkboxes because the following is not working:
$('checkCD'+id+'').attr('checked', false);
Thanks for your help!