rendered paste bodyfunction copyrow() { $("#assigned_roles tr:last").clone().find("select").each(function() {var $self = $(this); var i = $(this).attr('name').match(/[0-9]+/); $(this).attr({'selectedIndex': '-1', 'name' : $(this).attr('name').replace(/[0-9]+/,(parseInt(i)+1)), 'id' : $(this).attr('id').replace(/[0-9]+/,(parseInt(i)+1))}); }).end().find("input").each(function(){$(this).remove();}).end().find('a').each(function(){ $(this).attr('href','#'); $(this).click(function(){});}).click(function(e){e.preventDefault();$self.remove();}.end().appendTo("#assigned_roles");}