0

Here is My code

    <form name="formA">
      <input type="text" name="iptA" id="iptA" value="" />
      <input type="button" name="btnA" id="btnA" value="Click Here" onclick="count();"/>
      <input type="button" name="btnClr" id="btnClr" value="Clear" onclick="clear();"/>
      
    </form>
    <script type="text/javascript" charset="utf-8">
      var a = 0;
      document.formA.iptA.value = a;
      function count(){
        a++;
        document.formA.iptA.value = a;
      }
      
      function clear(){
        a = 0;
        document.formA.iptA.value = a;
      }
    </script>

In this, the function count() is working properly but the second function clear() is not working.

Thanks in advance

1 Answers1

2

Rename clear to foo and it will work. clear already has a meaning in browser pov - clearing the console

Royi Namir
  • 144,742
  • 138
  • 468
  • 792