Why don't you call the onclick function when I click on this checkbox?
function click()
{
alert("function is called");
}
<form action="regCheck.aspx" method="post" onsubmit="return submitF()">
<input type="checkbox" name="checkboxs" onclick="click()"/>
</form>
This is not my real file. I am just writing this part of my code so you can understand why my onclick function is not being called. If javascript opens an alert box when I click this checkbox, then I can use it. I hope you can help me. Thank!
+3
source to share
2 answers
Just change the name of your function from "click"
to a different name so that it is not obscured by the inline click
input function ):
function notcalledclick()
{
alert("function is called");
}
<form action="regCheck.aspx" method="post" onsubmit="return submitF()">
<input type="checkbox" name="checkboxs" onclick="notcalledclick()"/>
</form>
This is another reason to avoid adding inline javascript and prefer addEventListener
:
document.getElementById('someId').addEventListener('click', function(){
alert("function is called");
});
<form action="regCheck.aspx" method="post" onsubmit="return submitF()">
<input id=someId type="checkbox" name="checkboxs"/>
</form>
+2
source to share