title: Javascript - How to program a click counter?
body: <p>I have tried before, but it doesn't work. Is it any wrongs of the code?</p>
  
  <pre><code>&lt;script type ="text/javascript"&gt;
  function count()
  {
  var x = 0;
  x += 1;
  document.getElementById( "counting" ).value = x;
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;input type ="button" value = "Click" onclick = "count()"/&gt;&lt;br&gt;&lt;br&gt;
  &lt;input id = "counting" type = "text" /&gt;
  
  &lt;/body&gt;
  </code></pre>