var currentCol = 0; function addCol(oldKey, oldValue) { var newColNumber = currentCol + 1; if(typeof oldKey == "undefined") { oldKey = "Key-" + newColNumber + ""; } if(typeof oldValue == "undefined") { oldValue = ""; } var html = "
"; html += ""; html += "=>"+""; html += createTemplateTextfield("task[cols][value][]", "cols_value_" + newColNumber, oldValue, {module: workflowModuleName, refFields: true}); html += "
"; jQuery("#rows").append(html); currentCol++; return newColNumber; } function initCols() { jQuery.each(cols.key, function(index, value) { var colNumber = addCol(cols.key[index], cols.value[index]); }); } jQuery(function() { initCols(); InitAutocompleteText(); });