I want to get value of single checkbox when it is checked and unchecked.. I am currently working on codeigniter FW. I am getting the value of checkbox when clicked on it, but i am not able to get the value of unchecked box when clicked. please help me out!! My code is below.
<table>
<thead>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
<tr>
<td>
<input name="feature" type="checkbox" id="10" value="10" />
</td>
<td>
<input name="feature" type="checkbox" id="11" value="11" />
</td>
<td>
<input name="feature" type="checkbox" id="12" value="12" />
</td>
<td>
<input name="feature" type="checkbox" id="13" value="13" />
</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$("input:checkbox").change(function() {
var someObj = {};
someObj.fruitsGranted = [];
var feature , key;
$("input:checkbox").each(function() {
if ($(this).is(":checked")) {
key = someObj.fruitsGranted.push($(this).attr("feature"));
someObj.fruitsGranted.push($(this).attr("id"));
feature = $(this).attr("id");
//key = $(this).attr("feature");
}
});
alert("GRANTED: " + feature + " ok " + key);
});
</script>