codice:
for(var i=0; i<ps.length; i++){
   ps[i].onclick = (function(k){
        return function(){
             alert(k)
        }	
   })(i)
}
ciao