Hi,
I need to add objects from a form to another in order to send them all when the second form is submitted.
I’ve two forms in a jsp (I’ll call them Source and Target fro I want the objects contained in Source to be added to Target form). I’ve checked that in copyForm function all the elements of objSourceForm are copied into newElement variable. My problem is that I don’t know how I can add it to objTargetForm (the commented line):
function myFunction () {
var objForm1 = document.getElementById(“idForm1”);
var objForm2 = document.getElementById(“idForm2”);
copyForm (objForm1, objForm2);
objForm2.submit();
}
function copyForm(objSourceForm, objTargetForm) {
var num = objSourceForm.elements.length;
var objSource;
for (var i = num -1 ; i >= 0; i–) {
objSource = objSourceForm.elements[i];
if ((objSource.type != “button”)&&
(objSource.type != “submit”)) {
var newElement = objSource.cloneNode(true);
//how can I add newElement to objTargetForm?
}
}
}
Thanks