Martin,
Thank you for your reply.
I'll give some background on what I am doing. I have an HTML form that
is used for filling out text messages. (This form is created
dynamically using an XML Schema and XSLT.) Certain sections of the
message that the user is creating with this form may be repeated, so I
have created a button that runs a javascript function that copies the
portion of the form that may be repeated. The portion of the form that
can be repeated is surrounded by a form tag with a unique id that I
pass into the function. So I can do this:
var form1 = document.getElementById(sID).firstChild.cloneNode(true)
where sID is the id that is passed into the function and I get all of
the elements under the form tag.
With the script tags I am filling out a javascript associative array:
<script language="javascript" type="text/javascript">
fieldData["IDAEA1VIDAFA1V4"]
= {
DivID: "sic_code_4sic_code_or_filing_number",
ID: "IDATE0VIDAUE0V4",
Size: "3",
Type: "xsd:string",
Enum: "false",
minLength: "",
maxLength: "",
Length: "3",
minInclusive: "",
maxInclusive: "",
Pattern: "[A-Z0-9]{3}",
Enumeration: ""};
</script>
With the sID I am also able to reference the appropriate index of the
array. The array contains information that I use for validating the
input. Once I have a copy of the element, I can use the RegEx replace
to make all of the id's and the javascript (the array) unique.
I guess the bottom line is that I need some way to copy the elements I
need without doing it by reference (because then when I make changes to
the copied element the changes also go into the element I copied from).
I have tried to use a copy function like this:
function copy_obj(o) {
var c = new Object();
for (var e in o) {
c[e] = o[e];
}
return c;
}
but it appears that I am not getting an actual DOM object because it
doesn't recognize certain methods.
Anyhow, I think I have rambled on enough. I hope this gives you a
clear idea of what's happening, I appreciate any suggestions you might
have.
Many thanks.
Chip