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)
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.