second approach is not acceptable. because , I’m planning to use this for a dynamic row creation kind of staff . that requires target names to be different than source names. If I follow your second approach, then that will alter the name of source name also.
I am planning to create a dynamic row addition in a table. but those will have input text box, select box in them. I want to make sure that all those elements gets different names and ids.
Tables have their own set of DOM commands for adding, updating, and deleting table elements.
You should never need to put HTML tags in your JavaScript if you are intending to update the DOM. You can only ever use HTML tags in code that you are going to insert into the web page using innerHTML where you will never need to update parts of it afterwards. You can’t use innerHTML on parts of a table and so to update parts of a table you either need to use the general DOM calls or the table specific ones.