var inputStructure = [ {prompt: "Введите Фамилию", default_: "", field: "surname", placeholder: "surname", type: "text", }, {prompt: "Введите Имя", default_: "", field: "name", placeholder: "name", type: "text", }, {prompt: "Введите Отчество", default_: "", field: "fatherName", placeholder: "father name", type: "text", }, {prompt: "Введите возраст", default_: "0", field: "age", placeholder: "age", type: "number", }, ] var result = {}; function jqInputAnything(result, inputStructure, value1, value2){ document.write("
"); $("#save").click(function(){ for (var i = 0; i < inputStructure.length; i++) { result[inputStructure[i].field] = $("input:nth-of-type("+(i+1)+")").val(); } console.log(result); return false; }); } jqInputAnything(result, inputStructure, "Сохранить", "Сбросить");