Hi everyone. I am a novice at javascript and can't figure out the following:

I have a table where the user can press an "add more" button which duplicates the row and displays it on the next line. I use this for my site to have the user input stock prices which may be split in multiple orders after they execute them. Here is my JS code:

<script>
function insert(button) {var cell, newRow, row, sect;
if((cell = button.parentNode) && (row = cell.parentNode)
&& row.cloneNode && (sect = row.parentNode)
&& sect.insertBefore)
{
newRow = row.cloneNode(true);
/* If you need to alter the new row
* or its contents, do it here.
*/
sect.insertBefore(newRow, row.nextSibling);
}
}
</script>

This works fine. However, since I am submitting this with a form I need each cell id to have its own unique identifier. The way the code is now, the cloned cell has the same id as the original and only the data for one gets submitted. Any ideas would be much appreciated...

have you at least tried after
newRow = row.cloneNode(true);
to
newRow.setAttribute("id", 'theDesiredID');
or better:
newRow.id= "stringID";

?

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.