動的に追加されたテーブル行をJavascriptに追加(IE / FF互換)

1 Star2 Stars3 Stars4 Stars5 Stars (まだ評価されていません)
Loading...

<!DOCTYPE HTML PUBLIC " – // W3C // DTD HTML 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>テーブル行の動的追加と削除</ title>
<script language = "JavaScript">
<! –
// author:Robin
// email: [email protected]

Var rowIndex = 0;
関数addLine(obj){
変数objSourceRow = obj.parentNode.parentNode;
変数objTable = obj.parentNode.parentNode.parentNode.parentNode;
if(obj.value == 'Increase'){
rowIndex ++;
変数objRow = objTable.insertRow(rowIndex);
Var objCell;

objCell = objRow.insertCell(0);
objCell.innerHTML = "";

objCell = objRow.insertCell(1);
objCell.innerHTML = objSourceRow.cells [1] .innerHTML;

objCell = objRow.insertCell(2);
objCell.innerHTML = objSourceRow.cells [2] .innerHTML.replace(/ add /、 'delete');
}
その他{
objTable.lastChild.removeChild(objSourceRow);
rowIndex-;
}
}

関数removeLine(){

}

// – >
</ script>
</ head>
<body bgcolor = "#ffffff">
<form name = "form1" method = "post">
<table width = "400" 'border = "0">
<tr>
<td>基本情報</ td>
<td> <select name = "select">
<option value = "" selected> select </ option>
<option value = "1"> first </ option>
<option value = "2"> second </ option>
</ select> </ td>
<td> <input name = "basicinfo" type = "text" id = "basicinfo">
<input name = "add" type = "button" id = "add" value = "増加" onClick = "addLine(this)"> </ td>
</ tr>
<tr>
<td>その他の情報</ td>
<td> </ td>
<td> <input type = "text" name = "textfield"> </ td>
</ tr>
<tr>
<td> </ td>
<td> </ td>
<td> </ td>
</ tr>
<tr>
<td> </ td>
<td> </ td>
<td> </ td>
</ tr>
</ table>
</ form>
</ body>
</ html>


1 Star2 Stars3 Stars4 Stars5 Stars (まだ評価されていません)
Loading...
      この投稿は審査処理中  | 元のサイトへ