farahphp 0 Newbie Poster

Hi all,
I'm trying to add 3 rows on a click of a button and each row has 14 columns with text boxes and 4 of these textboxes has onblur events which dont work in the new rows added can someone help me with this problem the functions i tried are as follows

function insrow()
                {
                        var row  = document.getElementById("lastrow").value;
                        var nrow = row * 3;
                        var newrow=Number(nrow) + 1;
                        //alert(nrow);
                        //alert(newrow);
                        var tbody = document.getElementById("elctable");
                        var row = tbody.insertRow(newrow);

                        //var row = document.createElement("tr");
                        var c1 = document.createElement("TD");
                        c1.setAttribute("rowspan","3");
                        c1.setAttribute("id","nume"+nrow);
                        var c2 = document.createElement("td");
                        c2.innerHTML = 'East - ';
                        var c3 = document.createElement("td");
                        var c4 = document.createElement("td");
                        var inp1 = document.createElement("INPUT");
                        inp1.setAttribute("type","checkbox");
                        inp1.setAttribute("id","boxe"+nrow);
                        inp1.setAttribute("name","boxe["+nrow+"]");
                        c4.appendChild(inp1);
                        var c5 = document.createElement("td");
                        var inp2 = document.createElement("INPUT");
                        inp2.setAttribute("type","text");
                        inp2.setAttribute("id","fobcosteast"+nrow);
                        inp2.setAttribute("name","fobcosteast["+nrow+"]");
                        inp2.setAttribute("onblur","change(this.value,"+ nrow+")");
                        c5.appendChild(inp2);
                        var c6 = document.createElement("td");
                        var inp3 = document.createElement("INPUT");
                        inp3.setAttribute("type","text");
                        inp3.setAttribute("id","fobe"+nrow);
                        //inp3.setAttribute("name","fobcosteast["+nrow+"]");
                        c6.appendChild(inp3);
                        var c7 = document.createElement("td");
                        var inp4 = document.createElement("INPUT");
                        inp4.setAttribute("type","text");
                        inp4.setAttribute("id","smargine"+nrow);
                        //inp4.setAttribute("name","fobcosteast["+nrow+"]");
                        c7.appendChild(inp4);
                        var c8 = document.createElement("td");
                        var inp5 = document.createElement("INPUT");
                        inp5.setAttribute("type","text");
                        inp5.setAttribute("id","spricee"+nrow);
                        //inp5.setAttribute("name","fobcosteast["+nrow+"]");
                        c8.appendChild(inp5);
                        var c9 = document.createElement("td");
                        var inp6 = document.createElement("INPUT");
                        inp6.setAttribute("type","text");
                        inp6.setAttribute("id","freighte"+nrow);
                        //inp6.setAttribute("name","fobcosteast["+nrow+"]");
                        c9.appendChild(inp6);
                        var c10 = document.createElement("td");
                        var inp7 = document.createElement("INPUT");
                        inp7.setAttribute("type","text");
                        inp7.setAttribute("id","cmurphe"+nrow);
                        //inp7.setAttribute("name","fobcosteast["+nrow+"]");
                        c10.appendChild(inp7);
                        var c11 = document.createElement("td");
                        var inp8 = document.createElement("INPUT");
                        inp8.setAttribute("type","text");
                        inp8.setAttribute("id","celce"+nrow);
                        //inp8.setAttribute("name","fobcosteast["+nrow+"]");
                        c11.appendChild(inp8);
                        var c12 = document.createElement("td");
                        var inp9 = document.createElement("INPUT");
                        inp9.setAttribute("type","text");
                        inp9.setAttribute("id","msrpmargine"+nrow);
                        //inp9.setAttribute("name","fobcosteast["+nrow+"]");
                        c12.appendChild(inp9);
                        var c13 = document.createElement("td");
                        var inp10 = document.createElement("INPUT");
                        inp10.setAttribute("type","text");
                        inp10.setAttribute("id","msrpe"+nrow);
                        //inp10.setAttribute("name","fobcosteast["+nrow+"]");
                        c13.appendChild(inp10);
                        var c14 = document.createElement("td");
                        var inp11 = document.createElement("INPUT");
                        inp11.setAttribute("type","text");
                        inp11.setAttribute("id","notee"+nrow);
                        //inp11.setAttribute("name","fobcosteast["+nrow+"]");
                        c14.appendChild(inp11);
                        var inp12 = document.createElement("INPUT");
                        inp12.setAttribute("type","button");
                        inp12.setAttribute("id","undo"+nrow);
                        inp12.setAttribute("value","Undo");
                        c14.appendChild(inp12);
                        var c15 = document.createElement("td");
                        var inp13 = document.createElement("INPUT");
                        inp13.setAttribute("type","hidden");
                        inp13.setAttribute("id","dutye"+nrow);
                        //inp13.setAttribute("name","fobcosteast["+nrow+"]");
                        c15.appendChild(inp13);
                        var c16 = document.createElement("td");
                        var inp14 = document.createElement("INPUT");
                        inp14.setAttribute("type","hidden");
                        inp14.setAttribute("id","royaltye"+nrow);
                        //inp13.setAttribute("name","fobcosteast["+nrow+"]");
                        c16.appendChild(inp14);

                        row.appendChild(c1);
                        row.appendChild(c2);
                        row.appendChild(c3);
                        row.appendChild(c4);
                        row.appendChild(c5);
                        row.appendChild(c6);
                        row.appendChild(c7);
                        row.appendChild(c8);
                        row.appendChild(c9);
                        row.appendChild(c10);
                        row.appendChild(c11);
                        row.appendChild(c12);
                        row.appendChild(c13);
                        row.appendChild(c14);
                        row.appendChild(c15);
                        row.appendChild(c16);

                        newrow = newrow + 1;
                        nrow = nrow + 1;
                        var row1 = tbody.insertRow(newrow);

                        //var row = document.createElement("tr");
                        var ce1 = document.createElement("TD");
                        //ce1.setAttribute("rowspan","3");
                        ce1.setAttribute("id","nume"+nrow);
                        var ce2 = document.createElement("td");
                        ce2.innerHTML = 'West - ';
                        var ce3 = document.createElement("td");
                        var ce4 = document.createElement("td");
                        var inp1 = document.createElement("INPUT");
                        inp1.setAttribute("type","checkbox");
                        inp1.setAttribute("id","boxe"+nrow);
                        inp1.setAttribute("name","boxw["+nrow+"]");
                        ce4.appendChild(inp1);
                        var ce5 = document.createElement("td");
                        var inp2 = document.createElement("INPUT");
                        inp2.setAttribute("type","text");
                        inp2.setAttribute("id","fobcostwest"+nrow);
                        inp2.setAttribute("name","fobcostwest["+nrow+"]");
                        ce5.appendChild(inp2);
                        var ce6 = document.createElement("td");
                        var inp3 = document.createElement("INPUT");
                        inp3.setAttribute("type","text");
                        inp3.setAttribute("id","fobw"+nrow);
                        //inp3.setAttribute("name","fobcosteast["+nrow+"]");
                        ce6.appendChild(inp3);
                        var ce7 = document.createElement("td");
                        var inp4 = document.createElement("INPUT");
                        inp4.setAttribute("type","text");
                        inp4.setAttribute("id","smarginw"+nrow);
                        //inp4.setAttribute("name","fobcosteast["+nrow+"]");
                        ce7.appendChild(inp4);
                        var ce8 = document.createElement("td");
                        var inp5 = document.createElement("INPUT");
                        inp5.setAttribute("type","text");
                        inp5.setAttribute("id","spricew"+nrow);
                        //inp5.setAttribute("name","fobcosteast["+nrow+"]");
                        ce8.appendChild(inp5);
                        var ce9 = document.createElement("td");
                        var inp6 = document.createElement("INPUT");
                        inp6.setAttribute("type","text");
                        inp6.setAttribute("id","freightw"+nrow);
                        //inp6.setAttribute("name","fobcosteast["+nrow+"]");
                        ce9.appendChild(inp6);
                        var ce10 = document.createElement("td");
                        var inp7 = document.createElement("INPUT");
                        inp7.setAttribute("type","text");
                        inp7.setAttribute("id","cmurphw"+nrow);
                        //inp7.setAttribute("name","fobcosteast["+nrow+"]");
                        ce10.appendChild(inp7);
                        var ce11 = document.createElement("td");
                        var inp8 = document.createElement("INPUT");
                        inp8.setAttribute("type","text");
                        inp8.setAttribute("id","celcw"+nrow);
                        //inp8.setAttribute("name","fobcosteast["+nrow+"]");
                        ce11.appendChild(inp8);
                        var ce12 = document.createElement("td");
                        var inp9 = document.createElement("INPUT");
                        inp9.setAttribute("type","text");
                        inp9.setAttribute("id","msrpmarginw"+nrow);
                        //inp9.setAttribute("name","fobcosteast["+nrow+"]");
                        ce12.appendChild(inp9);
                        var ce13 = document.createElement("td");
                        var inp10 = document.createElement("INPUT");
                        inp10.setAttribute("type","text");
                        inp10.setAttribute("id","msrpw"+nrow);
                        //inp10.setAttribute("name","fobcosteast["+nrow+"]");
                        ce13.appendChild(inp10);
                        var ce14 = document.createElement("td");
                        var inp11 = document.createElement("INPUT");
                        inp11.setAttribute("type","text");
                        inp11.setAttribute("id","notew"+nrow);
                        //inp11.setAttribute("name","fobcosteast["+nrow+"]");
                        ce14.appendChild(inp11);
                        var inp12 = document.createElement("INPUT");
                        inp12.setAttribute("type","button");
                        inp12.setAttribute("id","undo"+nrow);
                        inp12.setAttribute("value","Undo");
                        ce14.appendChild(inp12);
                        var ce15 = document.createElement("td");
                        var inp13 = document.createElement("INPUT");
                        inp13.setAttribute("type","hidden");
                        inp13.setAttribute("id","dutye"+nrow);
                        //inp13.setAttribute("name","fobcosteast["+nrow+"]");
                        ce15.appendChild(inp13);
                        var ce16 = document.createElement("td");
                        var inp14 = document.createElement("INPUT");
                        inp14.setAttribute("type","hidden");
                        inp14.setAttribute("id","royaltye"+nrow);
                        //inp13.setAttribute("name","fobcosteast["+nrow+"]");
                        ce16.appendChild(inp14);

                        row1.appendChild(ce1);
                        row1.appendChild(ce2);
                        row1.appendChild(ce3);
                        row1.appendChild(ce4);
                        row1.appendChild(ce5);
                        row1.appendChild(ce6);
                        row1.appendChild(ce7);
                        row1.appendChild(ce8);
                        row1.appendChild(ce9);
                        row1.appendChild(ce10);
                        row1.appendChild(ce11);
                        row1.appendChild(ce12);
                        row1.appendChild(ce13);
                        row1.appendChild(ce14);
                        row1.appendChild(ce15);
                        row1.appendChild(ce16);

                        newrow = newrow + 1;
                        nrow = nrow + 1;
                        var row2 = tbody.insertRow(newrow);

                        //var row2 = document.createElement("tr");
                        var cw1 = document.createElement("TD");
                        //cw1.setAttribute("rowspan","3");
                        cw1.setAttribute("id","numl"+nrow);
                        var cw2 = document.createElement("td");
                        cw2.innerHTML = 'Like Item - ';
                        var cw3 = document.createElement("td");
                        var cw4 = document.createElement("td");
                        var inp1 = document.createElement("INPUT");
                        inp1.setAttribute("type","checkbox");
                        inp1.setAttribute("id","boxl"+nrow);
                        inp1.setAttribute("name","boxl["+nrow+"]");
                        cw4.appendChild(inp1);
                        var cw5 = document.createElement("td");
                        var inp2 = document.createElement("INPUT");
                        inp2.setAttribute("type","text");
                        inp2.setAttribute("id","fobcostwest"+nrow);
                        inp2.setAttribute("name","fobcostlike["+nrow+"]");
                        cw5.appendChild(inp2);
                        var cw6 = document.createElement("td");
                        var inp3 = document.createElement("INPUT");
                        inp3.setAttribute("type","text");
                        inp3.setAttribute("id","fobl"+nrow);
                        //inp3.setAttribute("name","fobcosteast["+nrow+"]");
                        cw6.appendChild(inp3);
                        var cw7 = document.createElement("td");
                        var inp4 = document.createElement("INPUT");
                        inp4.setAttribute("type","text");
                        inp4.setAttribute("id","smarginl"+nrow);
                        //inp4.setAttribute("name","fobcosteast["+nrow+"]");
                        cw7.appendChild(inp4);
                        var cw8 = document.createElement("td");
                        var inp5 = document.createElement("INPUT");
                        inp5.setAttribute("type","text");
                        inp5.setAttribute("id","spricel"+nrow);
                        //inp5.setAttribute("name","fobcosteast["+nrow+"]");
                        cw8.appendChild(inp5);
                        var cw9 = document.createElement("td");
                        var inp6 = document.createElement("INPUT");
                        inp6.setAttribute("type","text");
                        inp6.setAttribute("id","freightl"+nrow);
                        //inp6.setAttribute("name","fobcosteast["+nrow+"]");
                        cw9.appendChild(inp6);
                        var cw10 = document.createElement("td");
                        var inp7 = document.createElement("INPUT");
                        inp7.setAttribute("type","text");
                        inp7.setAttribute("id","cmurphl"+nrow);
                        //inp7.setAttribute("name","fobcosteast["+nrow+"]");
                        cw10.appendChild(inp7);
                        var cw11 = document.createElement("td");
                        var inp8 = document.createElement("INPUT");
                        inp8.setAttribute("type","text");
                        inp8.setAttribute("id","celcl"+nrow);
                        //inp8.setAttribute("name","fobcosteast["+nrow+"]");
                        cw11.appendChild(inp8);
                        var cw12 = document.createElement("td");
                        var inp9 = document.createElement("INPUT");
                        inp9.setAttribute("type","text");
                        inp9.setAttribute("id","msrpmarginl"+nrow);
                        //inp9.setAttribute("name","fobcosteast["+nrow+"]");
                        cw12.appendChild(inp9);
                        var cw13 = document.createElement("td");
                        var inp10 = document.createElement("INPUT");
                        inp10.setAttribute("type","text");
                        inp10.setAttribute("id","msrpl"+nrow);
                        //inp10.setAttribute("name","fobcosteast["+nrow+"]");
                        cw13.appendChild(inp10);
                        var cw14 = document.createElement("td");
                        var inp11 = document.createElement("INPUT");
                        inp11.setAttribute("type","text");
                        inp11.setAttribute("id","notel"+nrow);
                        //inp11.setAttribute("name","fobcosteast["+nrow+"]");
                        cw14.appendChild(inp11);
                        var inp12 = document.createElement("INPUT");
                        inp12.setAttribute("type","button");
                        inp12.setAttribute("id","undo"+nrow);
                        inp12.setAttribute("value","Undo");
                        cw14.appendChild(inp12);
                        var cw15 = document.createElement("td");
                        var inp13 = document.createElement("INPUT");
                        inp13.setAttribute("type","hidden");
                        inp13.setAttribute("id","dutyl"+nrow);
                        //inp13.setAttribute("name","fobcosteast["+nrow+"]");
                        cw15.appendChild(inp13);
                        var cw16 = document.createElement("td");
                        var inp14 = document.createElement("INPUT");
                        inp14.setAttribute("type","hidden");
                        inp14.setAttribute("id","royaltyl"+nrow);
                        //inp13.setAttribute("name","fobcosteast["+nrow+"]");
                        cw16.appendChild(inp14);

                        row2.appendChild(cw1);
                        row2.appendChild(cw2);
                        row2.appendChild(cw3);
                        row2.appendChild(cw4);
                        row2.appendChild(cw5);
                        row2.appendChild(cw6);
                        row2.appendChild(cw7);
                        row2.appendChild(cw8);
                        row2.appendChild(cw9);
                        row2.appendChild(cw10);
                        row2.appendChild(cw11);
                        row2.appendChild(cw12);
                        row2.appendChild(cw13);
                        row2.appendChild(cw14);
                        row2.appendChild(cw15);
                        row2.appendChild(cw16);

a simpler version i was trying which i found on web was duplicating the first row it doesnt help the events dont get copied

function addrow()
{
	var oNewRow = extable.rows[extable.rows.length - 1].cloneNode(true);
if (extable.childNodes[0].nodeName.toLowerCase() == "tbody")
   extable.childNodes[0].appendChild(oNewRow);
else
   extable.appendChild(oNewRow);
}

my table is dynamic