Implementation of Dynamic addition and deletion of javascript lines, and dynamic addition and deletion of javascript
Zookeeper
// Add rows
Function doAddRow ()
{
Var bodyObj = document. getElementById ("fm2_table_body"); // tbody id
Var rowCount = bodyObj. rows. length;
Var newRow = bodyObj. insertRow (rowCount ++ );
Var C1 = newRow. insertCell (0 );
Var C2 = newRow. insertCell (1 );
C1.setAttribute ("className", "td_class_1 ");
C2.setAttribute ("className", "td_class_1 ");
C1.innerHTML = "<input type = 'text' name = 'rzsgdwmc 'style = 'width: 100'/> ";
C2.innerHTML = "<input type = 'text' name = 'sdqj' style = 'width: 80'/> ";
}
// Delete a row
Function doDelete (inputobj ){
If (inputobj = null) return;
Var parentTD = inputobj. parentNode;
Var parentTR = parentTD. parentNode;
Var parentTBODY = parentTR. parentNode;
ParentTBODY. removeChild (parentTR );
}
Automatically encapsulate list data in action:
Define the attribute of each column in the Table in actionForm as an array. In this way, the attribute is automatically encapsulated as an array in action, and you can directly operate the array in Dao.