PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, October 15, 2022

[FIXED] Why did my onclick attribute in input type button is not working?

 October 15, 2022     dom, function, html, javascript, onclick     No comments   

Issue

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 😊


Solution

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



Answered By - Royi Namir
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing