<table>
<tr>
<td onclick="alert(this.parentElement.rowIndex)">
test
</td>
<td onclick="alert(this.parentElement.rowIndex)">
test
</td>
</tr>
<tr>
<td onclick="alert(this.parentElement.rowIndex)">
test
</td>
<td onclick="alert(this.parentElement.rowIndex)">
test
</td>
</tr>
</table>然后动态改变
<tr>
<td onclick="alert(this.parentElement.rowIndex)">
test
</td>
<td onclick="alert(this.parentElement.rowIndex)">
test
</td>
</tr>
<tr>
<td onclick="alert(this.parentElement.rowIndex)">
test
</td>
<td onclick="alert(this.parentElement.rowIndex)">
test
</td>
</tr>
</table>然后动态改变
解决方案 »
- 求教:google map api通过动态<script>方式引入出错
- Url.Content的问题。。在线等。。。。
- html中javascript函数未定义firebug
- 什么是框架?
- javascript 显示文本颜色
- 如何让从数据库字段中取出的文本按原有格式显示,???不在多行文本框内
- 代码狂吃内存的地方被我找到了,请问有什么解决办法?
- java swt调用js问题
- 怎么样取<body><img src="..."></body><html></html>中body里面的值或者img相关的值啊?
- 求一函数
- 发现一经典的网站,里面的文章挺感人,与大家分享
- 在若干个checkbox(同名)里,如何获取我点击的那个checkbox的下标。
<tr>
<td onclick="this.innerHTML='<input type=checkbox onclick=\'alert(this.name)\' name=AA'+this.parentElement.rowIndex+'>'">
test
</td>
<td onclick="this.innerHTML='<input type=checkbox onclick=\'alert(this.name)\' name=AA'+this.parentElement.rowIndex+'>'">
test
</td>
</tr>
<tr>
<td onclick="this.innerHTML='<input type=checkbox onclick=\'alert(this.name)\' name=AA'+this.parentElement.rowIndex+'>'">
test
</td>
<td onclick="this.innerHTML='<input type=checkbox onclick=\'alert(this.name)\' name=AA'+this.parentElement.rowIndex+'>'">
test
</td>
</tr>
</table>
var objRowsNum = document.getElementById("hid_SlRowsNum");
var rowsNum = parseInt(objRowsNum.value)
alert("-----rowsNum-----"+rowsNum);
var objSL = document.getElementsByName("chk_SecondLev");
var oTable = document.getElementById("estList1");
var i;
alert(objSL.length);
//delete the selected rows.
for(var j=0;j<rowsNum;j++){
if(objSL[j].checked){
alert("-------j------"+j);
i = objSL[j].parentElement.parentElement.rowIndex;
alert("-------i------"+i);
//oTable.deleteRow(i);
}
}
}
<html>
<head>
<title>工资录入</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
var myobj;
var Color= new Array(9);
Color[1] = "ff";
Color[2] = "ee";
Color[3] = "dd";
Color[4] = "cc";
Color[5] = "bb";
Color[6] = "aa";
Color[7] = "99";
Color[8] = "88";
Color[9] = "77";
Color[10] = "66";
Color[11] = "55";
Color[12] = "44";
Color[13] = "33";
Color[14] = "22";
Color[15] = "11";
Color[16] = "00";
function apply()
{
dtext.style.visiblity="visible";
myobj=event.srcElement;
itext.style.width=myobj.clientWidth;
itext.style.height=myobj.clientHeight;
dtext.style.left=myobj.offsetLeft+10;
dtext.style.top=myobj.offsetTop+51;
itext.value=myobj.innerText;
itext.select();
itext.focus();
}
function deapply()
{
myobj.innerText=itext.value;
itext.style.width=0;
}
function insertrow()
{
var row=pay.insertRow();
row.bgColor="#99ccff";
var cell=row.insertCell();
var htmltext="<input type=checkbox name='c'>";
cell.insertAdjacentHTML("afterBegin",htmltext);
for(var i=1;i<11;i++)
{
var cell=row.insertCell();
cell.attachEvent("onfocus",apply);
cell.innerText="aaa";
}
}
function delerow()
{
if(myobj!=null)
deapply();
itext.style.width=0;
var i=pay.rows.length;
while(i>1)
{
if(pay.rows(i-1).cells(0).all.c.checked)
pay.deleteRow(i-1);
i--;
}
}function fadeIn(rowindex,where) {
if (where >= 1) {
pay.rows(rowindex).bgColor="#" + Color[where] +"ccff";
where -= 1;
setTimeout("fadeIn("+rowindex+","+where+")", 15);
} else {
setTimeout("fadeOut("+rowindex+",1)", 15);
}
}
function fadeOut(rowindex,where) {
if (where <=16) {
pay.rows(rowindex).bgColor="#" + Color[where] +"ccff";
where += 1;
setTimeout("fadeOut("+rowindex+","+where+")", 15)
} else {
setTimeout("fadeIn("+rowindex+",16)", 15);
}
}
</script>
<style type="text/css">
td {
font-size: 12px;
line-height: 20px;
text-align: center;
}
th { font-size: 12px; line-height: 20px; font-weight: normal}
.btncolor
{
BORDER-RIGHT: #cccccc 1px solid;
BORDER-TOP: #ffffff 2px solid;
BORDER-BOTTOM: #bbbbbb 1px solid;
BORDER-LEFT: #ffffff 1px solid;
background-color: #99cccc;
font-size: 12px;
}
.inputcolor {
background-color: #99ccff;
}
-->
</style>
</head>
<body onload="javascript:itext.style.width=0">
<div id="dtext" style="position:absolute; left:483px; top:22px; width:84px; height:31px; z-index:1"><input type="text" id=itext class="inputcolor" onBlur="deapply();" style="BORDER-RIGHT:0px;BORDER-LEFT:0px;BORDER-TOP:0px;BORDER-BOTTOM:0px" size="1" name="text"></div>
<div align="center">工资数据录入 </div>
<form name="form1">
<table id="pay" width="95%" border="0" cellspacing="1" cellpadding="1" bgcolor=#666666>
<tr bgcolor="#0099ff">
<th align="center" >√</th>
<th align="center">主管部门</th>
<th align="center">企业名称</th>
<th align="center" >数据年月</th>
<th align="center">上交工资表日期</th>
<th align="center">市内职工数</th>
<th align="center">市外职工数</th>
<th align="center" >工资总额</th>
<th align="center" >欠资总额</th>
<th align="center">欠资人数</th>
<th align="center">备注</th>
</table>
</form>
<table width="95%" border="0" cellspacing="1" cellpadding="1" >
<tr>
<td align=right>
<input type=button value="增加" class="btncolor" onClick="insertrow()">
<input type=button value="删除" class="btncolor" onClick="delerow()">
<input type=button value="完成" class="btncolor" onClick="fadeIn(2,16)">
<input type=button value="完成1" class="btncolor" onClick="fadeIn(4,16)">
</td>
</tr>
</table>
</body>
</html>