I am displaying item id and title.there is also a link \"show items of this member\".while clicking on it it will display the items of that user.I am using ajax for this.The
You should probably change click
in script to on
Use this script
<script type="text/javascript">
var array = [];
$('#item').live('click', function() {
if ($(this).attr('checked')) {
// Add the new element if checked:
array.push($(this).attr('value'));
document.getElementById('hidden_field').value=array.join(',');
}
else {
// Remove the element if unchecked:
for (var i = 0; i < array.length; i++) {
if (array[i] == $(this).attr('value')) {
array.splice(i, 1);
}
}
}
});
</script>
You are not calling onclick function in your ajax generated code. In getdetails.php
Change
<input type="checkbox" name="item" id="item" value="'.$row[item_id].'">
to
<input type="checkbox" onclick="javascript:call_check()" name="item" id="item" value="'.$row[item_id].'">
Also id attribute of any html tag should be unique. This may not create any problem, but definitely not a good practice.