how to modify some js

y2kbgy2kbg New
edited January 2007 in Vanilla 1.0 Help
I have this code:
function moreFields(readspot) { counter++; var newFields = document.getElementById(readspot).cloneNode(true); newFields.id = ''; newFields.style.display = 'block'; var newField = newFields.childNodes; for (var i=0;i<newField.length;i++) { var theName = newField[i].name if (theName){ newField[i].name = theName + counter; } } var insertHere = document.getElementById('writeroot'); insertHere.parentNode.insertBefore(newFields,insertHere); document.getElementById("total").value = counter; }
That replicates whats in a div and increments the NAME of the elements. How can this be modifyied to increment the id also? I am really stuck on this.

Comments

This discussion has been closed.