Call any other function defined with own argument from another function by reading the property.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
function checkFun(i,name,code){
if(document.getElementById('name_'+i).checked==true){
console.log('checked '+i+' '+name+' '+code);
} else {
console.log('not checked '+i+' '+name+' '+code);
}
}
function checkAll(ths){
var k=$(ths);
if(k.prop('checked')==true){
for(var i=1;i<=document.getElementsByName('ids[]').length;i++){
var t=$('#name_'+i);
var funArgList=t.attr('onClick');
var funArgListArr1=funArgList.replace(/[('",)]/g,'_');
funArgListArr1=funArgListArr1.replace(/_+/g, '_');
var funArgListArr2=funArgListArr1.split('_');
if(document.getElementById('name_'+funArgListArr2[1]).checked==false){
document.getElementById('name_'+funArgListArr2[1]).checked=true;
checkFun(funArgListArr2[1],funArgListArr2[2],funArgListArr2[3]);
} else {
continue;
}
}
} else {
for(var i=1;i<=document.getElementsByName('ids[]').length;i++){
document.getElementById('name_'+i).checked=false;
}
}
}
</script>
</head>
<body>
<table>
<tr>
<td><input onclick="checkAll(this)" id="name_0" type="checkbox" name="" value="" /></td>
<td id="name_0">Select All</td>
</tr>
<tr>
<td><input onclick="checkFun('1','name1 h','code1')" id="name_1" type="checkbox" name="ids[]" value="" /></td>
<td id="name_1">name1</td>
</tr>
<tr>
<td><input onclick="checkFun('2','name2','code2')" id="name_2" type="checkbox" name="ids[]" value="" /></td>
<td id="name_2">name2</td>
</tr>
<tr>
<td><input onclick="checkFun('3','name3','code3')" id="name_3" type="checkbox" name="ids[]" value="" /></td>
<td id="name_3">name3</td>
</tr>
<tr>
<td><input onclick="checkFun('4','name4','code4')" id="name_4" type="checkbox" name="ids[]" value="" /></td>
<td id="name_4">name4</td>
</tr>
<tr>
<td><input onclick="checkFun('5','name5','code5')" id="name_5" type="checkbox" name="ids[]" value="" /></td>
<td id="name_5">name5</td>
</tr>
<tr>
<td><input onclick="checkFun('6','name6','code6')" id="name_6" type="checkbox" name="ids[]" value="" /></td>
<td id="name_6">name6</td>
</tr>
<tr>
<td><input onclick="checkFun('7','name7','code7')" id="name_7" type="checkbox" name="ids[]" value="" /></td>
<td id="name_7">name7</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
function checkFun(i,name,code){
if(document.getElementById('name_'+i).checked==true){
console.log('checked '+i+' '+name+' '+code);
} else {
console.log('not checked '+i+' '+name+' '+code);
}
}
function checkAll(ths){
var k=$(ths);
if(k.prop('checked')==true){
for(var i=1;i<=document.getElementsByName('ids[]').length;i++){
var t=$('#name_'+i);
var funArgList=t.attr('onClick');
var funArgListArr1=funArgList.replace(/[('",)]/g,'_');
funArgListArr1=funArgListArr1.replace(/_+/g, '_');
var funArgListArr2=funArgListArr1.split('_');
if(document.getElementById('name_'+funArgListArr2[1]).checked==false){
document.getElementById('name_'+funArgListArr2[1]).checked=true;
checkFun(funArgListArr2[1],funArgListArr2[2],funArgListArr2[3]);
} else {
continue;
}
}
} else {
for(var i=1;i<=document.getElementsByName('ids[]').length;i++){
document.getElementById('name_'+i).checked=false;
}
}
}
</script>
</head>
<body>
<table>
<tr>
<td><input onclick="checkAll(this)" id="name_0" type="checkbox" name="" value="" /></td>
<td id="name_0">Select All</td>
</tr>
<tr>
<td><input onclick="checkFun('1','name1 h','code1')" id="name_1" type="checkbox" name="ids[]" value="" /></td>
<td id="name_1">name1</td>
</tr>
<tr>
<td><input onclick="checkFun('2','name2','code2')" id="name_2" type="checkbox" name="ids[]" value="" /></td>
<td id="name_2">name2</td>
</tr>
<tr>
<td><input onclick="checkFun('3','name3','code3')" id="name_3" type="checkbox" name="ids[]" value="" /></td>
<td id="name_3">name3</td>
</tr>
<tr>
<td><input onclick="checkFun('4','name4','code4')" id="name_4" type="checkbox" name="ids[]" value="" /></td>
<td id="name_4">name4</td>
</tr>
<tr>
<td><input onclick="checkFun('5','name5','code5')" id="name_5" type="checkbox" name="ids[]" value="" /></td>
<td id="name_5">name5</td>
</tr>
<tr>
<td><input onclick="checkFun('6','name6','code6')" id="name_6" type="checkbox" name="ids[]" value="" /></td>
<td id="name_6">name6</td>
</tr>
<tr>
<td><input onclick="checkFun('7','name7','code7')" id="name_7" type="checkbox" name="ids[]" value="" /></td>
<td id="name_7">name7</td>
</tr>
</table>
</body>
</html>