I never tried to do what u r trying to... But I think u can try something like this:
//@source: the control we are going to use as source of our clone
//@destination: the control that we are going to use as destination to set the properties
function clone(source, destination) {
for ( var p in source ) {
try {
if ( p.toLocaleString().toLocaleLowerCase() != "innerhtml" && p.toLocaleString().toLocaleLowerCase() != "innertext" && p.toLocaleString().toLocaleLowerCase() != "id" && p.toLocaleString().toLocaleLowerCase() != "outertext") {
var sourceVal = source.getAttribute(p);
destination.setAttribute(p, sourceVal);
if ( typeof(source.getAttribute(p).length) != "undefined" ) {
clone(source.getAttribute(p), destination.getAttribute(p));
}
}
} catch ( e ) {
window.status = e.message;
}
}
}
the function doesn't set the id because we want to keep our original id, innertext, outertext and the innerhtml because it will override the control's rendering format
or we can append the control dynamycally like this:
//@source: the control to clone (not the id)
//@target: the control where our clone will be appended
function clone(source, target) {
var destination = document.createElement(source.tagName);
destination.id = new Date().getUTCMilliseconds(); //a new id to the cloned control
target.appendChild(destination); //the control where our clone will be appended
for ( var p in source ) {
try {
if ( p.toLocaleString().toLocaleLowerCase() != "innerhtml" && p.toLocaleString().toLocaleLowerCase() != "innertext" && p.toLocaleString().toLocaleLowerCase() != "id" && p.toLocaleString().toLocaleLowerCase() != "outertext") {
var sourceVal = source.getAttribute(p);
destination.setAttribute(p, sourceVal);
if ( typeof(source.getAttribute(p).length) != "undefined" ) {
clone(source.getAttribute(p), destination.getAttribute(p));
}
}
} catch ( e ) {
window.status = e.message;
}
}
}
hope this helps
Age is a very high price to pay for maturity. ~Tom Stoppard