Click to See Complete Forum and Search --> : How to dynamically create rows within a Form?


ashas
09-07-2003, 09:13 PM
Hello,

I have created a Form, within this form there are fields that I would like the user to be able to add more rows to if necessary..

I am trying to use the cloneNode function to do this..

I have found the following code which I think will work....

function addRowSubmit(ordId,drId)
{
alert("You are in addrow func");
theRow=document.getElementById(ordId);
theRow.parentNode.insertBefore(theRow.cloneNode (true),document.getElementById(drId));
}

I am getting an error on the second line of the function, the error reads something like "Error:Object required"

I have no idea what this error means..

My questions are:

1) Does the code above look incorrect?
2) What type of variable does the getElementById() accept?

Hope someone can help!

Thanks,
Asha

Fang
09-08-2003, 01:53 AM
Wrong order:

theRow.parentNode.insertBefore(document.getElementById(drId).cloneNode(true), theRow);