$(function(){ function getIndex(x){ return $('#a'+x).val(); } var arr = $('input'); for(var i=0;i