I have written a piece of code. On clicking on a button corresponding function should be called. While the logic works for funcB and funcD i.e. they get invoked on clicking FieldB and FieldD. FunctionA gets called for some reason on page load.Can someone explain what am I doing wrong here?Happy to share additional code if doesn't make sense.
function funcA(array){alert("Invoked");}
function init() {
loadData();
document.getElementById("FieldA").onclick = funcA(array1);
document.getElementById("FieldB").onclick = funcB;
document.getElementById("FieldC").onclick = funcA(array2);
document.getElementById("FieldD").onclick = funcD;
}
window.onload = init;