Łatwo się to robi np. jQuery.
Natomiast bez użycia bibliotek znalazłem coś takiego (
źródło):
"We could also use insertBefore instead of appendChild, or even manually add the new element to the end of the end of the childNodes collection. Using replaceChild, we could also overwrite existing nodes. It is also possible to copy a node using
cloneNode(true). This returns a copy of the node but does not automatically add it into the childNodes collection. Using element.removeChild(referenceToChildNode), we can remove existing nodes."
Natomiast nie wiem jak to się ma do różnych przeglądarek ;/
Na szybko skrobnięty kod:
<?php
<html>
<head>
<title>Tit</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function dodaj() {
var f = document.getElementById('frm');
var f2 = f.cloneNode(true);
window.document.childNodes[0].appendChild(f2);
}
</script>
<style type="text/css">
</style>
</head>
<body>
<div id="frm">
<form>
<input type="text" name="nazwa" value="lala" />
</form>
</div>
<div><input type="button" value="Kopiuj" onclick="dodaj();return false;"/></div>
</body>
</html>
?>
Sprawdziłem w Operze i Firefoxie.
Pozdrawiam