lundi 24 mai 2021

Function is not getting triggerd when clicking the checkbox

This is my code I want to trigger the function myfunction() when I click the checkbox and again call another function inside the myfunction when certain condition gets true. But the issue is whenever I click the checkbox, myFunction() is not getting triggered (I have put the alert statement to check that). Can anyone please tell what I am doing wrong here?

for(let k=0; k< plans.length ; i++){
  var headerCell = document.createElement("TH");
  headerCell.innerHTML = allplans["el"][k]["[Plan]"] + 
    '<input type="checkbox" id="c4" onchange= "myfunction()" value="on" name="cb4" />'
  headerCell.className = "header"
  row.appendChild(headerCell);
}

function myfunction(){
  alert("checkeddd")
  if (condition){
    //call another function
  }
}



Aucun commentaire:

Enregistrer un commentaire