<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<Script Language="Javascript">
var cGetRow=-99999;
var i=0;
function
AddRow() {
//添加一行
var newTr = tab1.insertRow(0);
//添加两列
var newTd0 = newTr.insertCell(0);
var newTd1 = newTr.insertCell(0);
//设置列内容和属性
newTd0.innerHTML = '<input type=checkbox id="box"+i onClick="GetRow()">';
newTd1.innerText = '新增加行';
}
function DelRow(iIndex) {
//删除一行
if (iIndex == -99999)
alert("系统提示:没有选中行号!");
else
tab1.deleteRow(iIndex);
}
function GetRow() {
//获得行索引
cGetRow = window.event.srcElement.parentElement.parentElement.rowIndex;
alert(cGetRow)
}
function ShowRow() {
//显示行号
alert(cGetRow);
}
</script>
</head>
<body>
<table id="tab1" border=1>
</table>
<input type="submit" name="Submit" value="AddRow" οnclick="javascript:AddRow();">
<input type="submit" name="Submit" value="DelRow" οnclick="javascript:DelRow(cGetRow);">
<input type="submit" name="Submit" value="ShowRow" οnclick="javascript:ShowRow();">
</body>
<Script Language="Javascript">
var cGetRow=-99999;
var i=0;
function
AddRow() {
//添加一行
var newTr = tab1.insertRow(0);
//添加两列
var newTd0 = newTr.insertCell(0);
var newTd1 = newTr.insertCell(0);
//设置列内容和属性
newTd0.innerHTML = '<input type=checkbox id="box"+i onClick="GetRow()">';
newTd1.innerText = '新增加行';
}
function DelRow(iIndex) {
//删除一行
if (iIndex == -99999)
alert("系统提示:没有选中行号!");
else
tab1.deleteRow(iIndex);
}
function GetRow() {
//获得行索引
cGetRow = window.event.srcElement.parentElement.parentElement.rowIndex;
alert(cGetRow)
}
function ShowRow() {
//显示行号
alert(cGetRow);
}
</script>
</head>
<body>
<table id="tab1" border=1>
</table>
<input type="submit" name="Submit" value="AddRow" οnclick="javascript:AddRow();">
<input type="submit" name="Submit" value="DelRow" οnclick="javascript:DelRow(cGetRow);">
<input type="submit" name="Submit" value="ShowRow" οnclick="javascript:ShowRow();">
</body>