I am trying to create a loop to create many functions so that when a user clicks the thumb up button it runs the correct .php document. It works great when I remove the loop and just give var i a specific number but as soon as i try to make it into a loop, at the alert(i) i get 10 on the first loop.
 var i=1;
 while ( ++i < 10 ) {
    $('#thumbup' + i).click(function() {
        var userid = $('#theuser' + i).text();
        var url = "_thumbup.php?userid=" + userid;
        //alert(url);
        $('#thumbup' + i).hide();
        $('#thumbdown' + i).hide();
        $("#toggle").css("display","block");
        alert(i); // Give me 10 on first loop?!?
        // get the URL
        http = new XMLHttpRequest(); 
        http.open("GET", url, true);
        http.send(null);
        // prevent form from submitting
        return false;   
    }); 
  }
 
     
    