JAVASCRIPT

애니위즈 2011. 3. 8. 17:57

<SCRIPT>
function add_rows(obj){
 var table = document.getElementById(obj);
 var ind = table.rows.length;
 var oRow = table.insertRow(ind);
 oRow.style.height = "28px";
 oRow.style.backgroundColor="white";
 
 var oCelll = oRow.insertCell(0);
 var oCell2 = oRow.insertCell(1);
 var oCell3 = oRow.insertCell(2);
 var oCell4 = oRow.insertCell(3);
 var oCell5 = oRow.insertCell(4);
 
 oCelll.align = "center";
 oCell2.align = "center";
 oCell3.align = "center";
 oCell4.align = "center";
 oCell5.align = "center";
 
 oCelll.innerHTML = "1";
 oCell2.innerHTML = "2";
 oCell3.innerHTML = "3";
 oCell4.innerHTML = "4";
 oCell5.innerHTML = "5";
}

function del_rows(obj){
 var table = document.getElementById(obj);
 var ind = table.rows.length;
 var oRow = table.deleteRow(ind-1);
}
</SCRIPT>
 <INPUT onclick="add_rows('tbl1');" value=추가 type=button> <INPUT onclick="del_rows('tbl1');" value=삭제 type=button>
<TABLE id=tbl1 border=1>
<TBODY>
<TR>
<TD>1</TD>
<TD>2</TD>
<TD>3</TD>
<TD>4</TD>
<TD>5</TD></TR></TBODY></TABLE>

 

 

웹프로그램개발 애니위즈 http://anywiz.co.kr