title: Javascript Count click on link and store it in cookie
body: <p>i'm newbee in javascript language and have a problem :</p>
  
  <p>I have a script who count click on a link and display none this link when 20 clicks.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var compteur=0;
      function submitOnce()
      {
      var i,h5s = document.getElementsByTagName('h5'), nbr = h5s.length;
  
      compteur +=1;
      if (compteur==20){
      for (i=0;i&lt;nbr;i++) {
          document.getElementsByTagName("h5")[i].style.visibility = "hidden";
          document.getElementById("quota").style.display = "block";
      }
      };
      };
   &lt;/script&gt;
  </code></pre>
  
  <p>Now, i if user navigate to other section of the web site, count is reset. So i would like to store the result of the count in cookie.</p>
  
  <p>I found a script who describe the process to store number of visits of a web site in cookie.</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
    &lt;!--
    function cherchevaleur()
    {
     var valeur = "";
     if(document.cookie)
     {
      valeurdepart = document.cookie.indexOf("=") + 1;
      valeurfin = document.cookie.indexOf(";");
      if(valeurfin == -1) valeurfin = document.cookie.length;
      valeur = document.cookie.substring(valeurdepart,valeurfin);
     }
     return valeur;
    }
  
    function fixervaleur(indic, valeur, expire)
    {
     var maintenant = new Date();
     var temps = new Date(maintenant.getTime() + expire);
     document.cookie = indic+"="+valeur+"; expires="+temps.toGMTString()+";";
    }
  
    function compteur()
    {
     var tpsexpire = 1000*60*60*24*1;
     var nombre = cherchevaleur();
     var compte = 0;
     if(nombre != "") compte = parseInt(nombre);
     if(document.cookie)
     {
      compte = compte + 1;
      fixervaleur("compte",compte,tpsexpire);
     }
     else
     {
      compte = 1;
      fixervaleur("compte",compte,tpsexpire);
     }
    alert("C'est votre " + compte + "ème visite sur cette page!");
    }
    //--&gt;
   &lt;/script&gt;
  </code></pre>
  
  <p>But i don't understand how to insert my count script. Is there someone who could help me to understand ?</p>
  
  <p>Thanks</p>