Skip to content

Instantly share code, notes, and snippets.

@coolhome
Created April 28, 2013 18:55
Show Gist options
  • Save coolhome/5477985 to your computer and use it in GitHub Desktop.
Save coolhome/5477985 to your computer and use it in GitHub Desktop.
var i = 0;
function appendRow() {
$('#row')
.clone()
.attr('id', '')
.find(':input')
.each(function(index) {
$(this).attr({
'id': function(_, id) { return id + '[' + i + '_' + (index + 1) + ']' },
'name': function(_, name) { return name + '[' + i + '_' + (index + 1) + ']' },
});
})
.end()
.appendTo("#tblrows");
i++;
}
$(function() {
if(i == 0) {
appendRow();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment