title: Loop with 8 times
body: <p>How I do a Loop with 8 times with this entire function?</p>
  
  <p>Only changing the var n</p>
  
  <pre><code>$(document).ready(function(){
      var n=2;                                   
      $forms = $('#form'+n);
      $('#toogle'+n).hide();
      $('#hide'+n).hide();
  
  $('a').bind('click', function(){
          switch(this.id){
              case 'c'+n:
                  $('#change'+n).hide();
                  $('#phone'+n).hide();
                  $('#hide'+n).show();
                  $('#toogle'+n).show(); 
                  return false;
                  break;
               case 'd'+n:
                  $('#change'+n).show();
                  $('#phone'+n).show();
                  $('#hide'+n).hide();
                  $('#toogle'+n).hide(); 
                  return false;
                  break;
          }
      })
  
      $forms.bind('submit', function(){
          var $button = $('button',this).attr('disabled',true);
          var params = $(this.elements).serialize();
  
          var self = this;
          $.ajax({
              type: 'POST',
              url: this.action,
              data: params,
  
          beforeSend: function(){
                  $('#phone'+n).show();
                  $('#hide'+n).hide();
  
                  $('#phone'+n).html("Loading...");
              },
              success: function(txt){
  
                  $('#top'+n).show();
                  $('#cadastro'+n).hide   ();
                  $('#hide'+n).hide   ();
                  $('#toogle'+n).hide();
                  $('#change'+n).show();
  
                  $button.attr('disabled',false);
  
                  $('#phone'+n).html(txt);
  
                  self.reset();
              },
  
              error: function(txt){
                  $('#phone'+n).html(txt);
              }
          })
          return false;
      });
  
  });
  </code></pre>