I want to replace form field names with the label text in the following code. I am just missing a line perhaps
var template = $('#idRequestDetails').clone();
template.find('input,select,textarea,table').each(function(){
var newId = this.id.substring(0, this.id.length-1) + uniqueId;
$(this).prev().attr('for', newId); // update label for
this.name = this.id = newId; // update id and name (assume the same)
});