Skip to content Skip to sidebar Skip to footer

OnChange Event Handler Not Working

I'm using onchange event handler with an input element. I know it's simple, I just added an onchange attribute. But it's not at all working also not showing any kind of error in co

Solution 1:

select is a reserved word in JavaScript (sort of).

<script type="text/javascript">
  function _select(a) {
    document.getElementById("demo").innerHTML = a;
  }
</script>
<p id="demo"></p>

<input type="checkbox" onchange="_select('XYZ')">


Solution 2:

Javascript has a list of reserved keywords which cannot be used as function names or variable names.

For a complete list, check this link: http://www.w3schools.com/js/js_reserved.asp


Solution 3:

<script type="text/javascript">
  function select1(a) {
    console.log(a);
    document.getElementById("demo").innerHTML = a;
  }
</script>

<input type="checkbox" onchange="select1('XYZ')" name="xyz" value="xyz">
<p id="demo"></p>
you should change your function name becouse there is collision occurs that's why it's not working try above

Post a Comment for "OnChange Event Handler Not Working"