Saturday 15 September 2012

javascript - add previous row data to dynamically generated row -


I have a table with the exchange changes of the selected variable, it generates rows What I want to do is that The data I wrote in the first line should be copied to the generated rows. This is my table and java script

   & Lt; Input type = "checkbox" onclick = "check all (this)" & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt ;! - & lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> - & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; Choose name = "mode" id = "mode" onchange = "adro ('engagement')" & gt; & Lt; Option value = "" & gt; Add more rows with the same lines with the above & lt; / Option & gt; & Lt; Option value = "1" & gt; 1 more & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 more & lt; / Options & gt; & Lt; Option value = "3" & gt; 3 more & lt; / Options & gt; & Lt; Option value = "4" & gt; 4 more & lt; / Options & gt; & Lt; Option value = "5" & gt; 5 more & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Form & gt; & Lt; Script language = "javascript" & gt; Function addrow (tableID) {var table = document.getElementById (tableID); Var rowCount = table.rows.length; Var line = table.insertRow (rowCount); Var colCount = table.rows [0] .cells.length; Var e = document.getElementById ("mode"); Var strUser = e.options [e.selectedIndex] .value; (Var j = 0; j & lt; strUser; j ++) {for (var i = 0; i & lt; colcount; i ++) {var Newscel = row.insertCell (i); Newcell.innerHTML = Table. Fury [1] Seals [I] WinnerHTML; } Ver line = table.insertRow (rowCount); }} & Lt; / Script & gt;    

If you are already using jQuery, you can do this $ ('I', 'i', 'i', 'i', 'i' {LastRow = $ ('# engagement tr'). Last () .clone (); $ (' # Traged tr '). Last (). After (lastRow);}}};

Demo ---->

No comments:

Post a Comment