how to trigger onclick function in Html Check box when its status changed to checked
I have a page which lists the Employee. In the left side of the list i have checkboxes to select. So, i have Select all checkbox also in header.When i click on select all check box it will selects all check boxes below. But i have javascript in onclick event for checkboxes in down not for select all checkbox. when i select all the checkboxes using select all, the below checkbox onclik event is not getting called. i verified with onchange, onselect event also.
<display:column style="width:2%"
title="<input type='checkbox' id='allCheck' name='allCheck' value='propertyConcernId'
开发者_JAVA百科onclick='checkAll(this);'/>">
<s:checkbox name="propertyConcernId" fieldValue="%{prtyCrnId}" tabindex="7"
id="check_%{#attr.row.propertyId}"
onclick="verifyCheckAll(this);assignValue('select_%{#attr.row.propertyId}','check_%{#attr.row.propertyId}')" />
</display:column>
how to get this done?Help on this.
verifyCheckAll = function(childCheckBox) {
$(document).ready(function() {
var isAllChecked = true;
$("input:checkbox[name="+childCheckBox.name+"]").each(function() {
if (this.checked == false) {
isAllChecked = false;
}
});
$("input[name=allCheck]").attr('checked', isAllChecked);
isRecSelected(childCheckBox.name);
});
}
This is the script i am using to select the child check boxes
In the checkAll() function go to every checkbox you have and call for each what you have in onClick event for propertyConcernId fields.
I have achieved this by the following way,
callChildClick = function(parentChkBox) {
var checked_status = parentChkBox.checked;
$(document).ready(function() {
$("input:checkbox[name="+parentChkBox.value+"]").each(function() {
this.click();
});
});
isRecSelected(parentChkBox.value);
}
精彩评论