<script type="text/javascript">
window.onload = function(){
var elem = document.getElementsByName('input'), i = elem.length;
while(i--){
elem[i].onclick = function(i){
return function(){
alert(this.value)
};
}(i);
}
};
</script>
<input type='text' value='1' name='input' />
<input type='text' value='2' name='input' />
<input type='text' value='3' name='input' />