일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- dock
- WebLogic
- sencha touch
- Android
- GPS
- PLSQL
- tomcat
- JSON
- oracle
- node.js
- 가우스
- Ajax
- MFC
- 전자정부프레임워크
- iBATIS
- 선택적조인
- PHP
- MySQL
- jsr 296
- jQuery
- Eclipse
- Spring
- JDOM
- Google Map
- phonegap
- rowspan
- swingx
- ibsheet
- Struts
- appspresso
- Today
- Total
Where The Streets Have No Name
동적 테이블 추가/삭제 및 폼 전송 예제 본문
http://www.jakartaproject.com/article/javascripttip/1113828539324
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=euc-kr">
<title>동적 테이블 추가/삭제 및 폼 전송 예제</title>
<script language="javascript">
function addRow() {
var oRow = dyntbl1.insertRow();
oRow.onmouseover=function(){dyntbl1.clickedRowIndex=this.rowIndex};
var oCell1 = oRow.insertCell();
var oCell2 = oRow.insertCell();
var oCell3 = oRow.insertCell();
var oCell4 = oRow.insertCell();
oCell1.innerHTML = "<input type=text name=itemcode>";
oCell2.innerHTML = "<input type=text name=itemname>";
oCell3.innerHTML = "<input type=text name=itemnum>";
oCell4.innerHTML = "<input type=button value=" X " onClick="delRow()">";
}
function delRow() {
dyntbl1.deleteRow(dyntbl1.clickedRowIndex);
}
</script>
</head>
<body>
<form>
<input type=submit>
<table id=dyntbl1 border=1>
<tr>
<th>품목코드</th>
<th>품목명</th>
<th>갯수</th>
<th><input type=button value=" + " onClick="addRow()"></th>
</tr>
<tr onMouseOver="dyntbl1.clickedRowIndex=this.rowIndex">
<td><input type=text name=itemcode></td>
<td><input type=text name=itemname></td>
<td><input type=text name=itemnum></td>
<td><input type=button name=dyntbl1_delRow value=" X " onClick="delRow()"></td>
</tr>
<tr onMouseOver="dyntbl1.clickedRowIndex=this.rowIndex">
<td><input type=text name=itemcode></td>
<td><input type=text name=itemname></td>
<td><input type=text name=itemnum></td>
<td><input type=button name=dyntbl1_delRow value=" X " onClick="delRow()"></td>
</tr>
</table>
</form>
</body>
</html>
rowIndex는 맨위부터 0에서 시작되서 증가됨