代码实现的是按ENTER键插入一行.序号那里不会自动增加,请帮我修改一下.谢谢大家了..另外如果再帮我加上一个按"DEL"键删除的功能就更完美了.谢谢大家了. <table width='100%' border='1' cellpadding='0' cellspacing='0'>
<tr align='center' bgcolor='#E6E6E6'>
<td width='30' height='28' align="center" bgcolor='#E6E6E6'>序号</td>
<td width="100" bgcolor='#E6E6E6'>日期</td>
<td width="150" bgcolor='#E6E6E6'>A</td>
<td width="100" bgcolor='#E6E6E6'>B</td>
<td width="100" bgcolor='#E6E6E6'>C</td>
<td bgcolor='#E6E6E6'>D</td>
<td width="70" bgcolor='#E6E6E6'>E</td>
<td width="40" bgcolor='#E6E6E6'>F</td>
<td width="80" bgcolor='#E6E6E6'>G</td>
<td bgcolor='#E6E6E6'>H</td>
</tr>
<tr id='addtable' align='center' bgcolor='#FFFFFF'>
<td height="28"><input size="3" type="hidden" >ID</td>
<td><input class="inputbian" size="10" type="hidden">2011-3-24</td>
<td><input class="inputbian" style="width=140" size="18" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=100" size="12" onmouseover='this.focus()'></td>
<td><input style="width=100" class="inputbian" size="12" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=60" size="5" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=40" size="8" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=30" size="5" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=70" size="10" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=70" size="10" onmouseover='this.focus()'></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<script language="JavaScript">var i=1;
//设置行号
function Addrow(){ var newTR = addtable.cloneNode(true);
newTR.id="a"+(++i);
addtable.parentNode.insertAdjacentElement("beforeEnd",newTR);
rows=document.getElementById("rows").rowIndex;
RowReset();
}function ShortcutKey(){
if(window.event.keyCode==13)
Addrow()
}
document.onkeydown=ShortcutKey;
</script>
<tr align='center' bgcolor='#E6E6E6'>
<td width='30' height='28' align="center" bgcolor='#E6E6E6'>序号</td>
<td width="100" bgcolor='#E6E6E6'>日期</td>
<td width="150" bgcolor='#E6E6E6'>A</td>
<td width="100" bgcolor='#E6E6E6'>B</td>
<td width="100" bgcolor='#E6E6E6'>C</td>
<td bgcolor='#E6E6E6'>D</td>
<td width="70" bgcolor='#E6E6E6'>E</td>
<td width="40" bgcolor='#E6E6E6'>F</td>
<td width="80" bgcolor='#E6E6E6'>G</td>
<td bgcolor='#E6E6E6'>H</td>
</tr>
<tr id='addtable' align='center' bgcolor='#FFFFFF'>
<td height="28"><input size="3" type="hidden" >ID</td>
<td><input class="inputbian" size="10" type="hidden">2011-3-24</td>
<td><input class="inputbian" style="width=140" size="18" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=100" size="12" onmouseover='this.focus()'></td>
<td><input style="width=100" class="inputbian" size="12" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=60" size="5" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=40" size="8" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=30" size="5" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=70" size="10" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=70" size="10" onmouseover='this.focus()'></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<script language="JavaScript">var i=1;
//设置行号
function Addrow(){ var newTR = addtable.cloneNode(true);
newTR.id="a"+(++i);
addtable.parentNode.insertAdjacentElement("beforeEnd",newTR);
rows=document.getElementById("rows").rowIndex;
RowReset();
}function ShortcutKey(){
if(window.event.keyCode==13)
Addrow()
}
document.onkeydown=ShortcutKey;
</script>
解决方案 »
- js 浏览器可见区域的网页内容
- 一小段html代码,很简单,运行不正确,能不能帮看看
- name 与id的区别
- jsp的问题
- 下拉框选择,跳转到相应的页面,怎么实现?
- 急,怎样在JavaScript中取checkbox的值
- 怎么通过点击右键获得某一个ID号?比如:<a href=aaa.htm> adfad</a> 里的aaa.htm 连接一样的。
- 如何控制输入框的长度啊,要用css吗?怎么写啊
- js 或者其他语言 有没有办法让指定页面置顶显示,不被其他程序盖住,当此页面是最小化时,就让他最大化显示到屏幕最前面
- 图片分块显示不同颜色
- 层的滑动效果js
- javascript 里面有类,为什么又要有原型的存在?
<table width='100%' border='1' cellpadding='0' cellspacing='0'>
<tr align='center' bgcolor='#E6E6E6'>
<td width='30' height='28' align="center" bgcolor='#E6E6E6'>序号</td>
<td width="100" bgcolor='#E6E6E6'>日期</td>
<td width="150" bgcolor='#E6E6E6'>A</td>
<td width="100" bgcolor='#E6E6E6'>B</td>
<td width="100" bgcolor='#E6E6E6'>C</td>
<td bgcolor='#E6E6E6'>D</td>
<td width="70" bgcolor='#E6E6E6'>E</td>
<td width="40" bgcolor='#E6E6E6'>F</td>
<td width="80" bgcolor='#E6E6E6'>G</td>
<td bgcolor='#E6E6E6'>H</td>
</tr>
<tr id='addtable' align='center' bgcolor='#FFFFFF'>
<td height="28">1</td>
<td><input class="inputbian" size="10" type="hidden">2011-3-24</td>
<td><input class="inputbian" style="width=140" size="18" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=100" size="12" onmouseover='this.focus()'></td>
<td><input style="width=100" class="inputbian" size="12" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=60" size="5" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=40" size="8" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=30" size="5" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=70" size="10" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=70" size="10" onmouseover='this.focus()'></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<script language="JavaScript">var i=1;
//设置行号
function Addrow(){ var newTR = addtable.cloneNode(true);
newTR.id="a"+(++i);
addtable.parentNode.insertAdjacentElement("beforeEnd",newTR);
newTR.children[0].innerHTML=i;
}function ShortcutKey(){
if(window.event.keyCode==13)
Addrow()
}
document.onkeydown=ShortcutKey;
</script>
<table id="table1" width='100%' border='1' cellpadding='0' cellspacing='0'>
<tr align='center' bgcolor='#E6E6E6'>
<td width='30' height='28' align="center" bgcolor='#E6E6E6'>序号</td>
<td width="100" bgcolor='#E6E6E6'>日期</td>
<td width="150" bgcolor='#E6E6E6'>A</td>
<td width="100" bgcolor='#E6E6E6'>B</td>
<td width="100" bgcolor='#E6E6E6'>C</td>
<td bgcolor='#E6E6E6'>D</td>
<td width="70" bgcolor='#E6E6E6'>E</td>
<td width="40" bgcolor='#E6E6E6'>F</td>
<td width="80" bgcolor='#E6E6E6'>G</td>
<td bgcolor='#E6E6E6'>H</td>
</tr>
<tr id='addtable' align='center' bgcolor='#FFFFFF'>
<td height="28">1</td>
<td><input class="inputbian" size="10" type="hidden">2011-3-24</td>
<td><input class="inputbian" style="width=140" size="18" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=100" size="12" onmouseover='this.focus()'></td>
<td><input style="width=100" class="inputbian" size="12" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=60" size="5" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=40" size="8" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=30" size="5" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=70" size="10" onmouseover='this.focus()'></td>
<td><input class="inputbian" style="width=70" size="10" onmouseover='this.focus()'></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<script language="JavaScript">var i=1;
//设置行号
function Addrow(){ var newTR = addtable.cloneNode(true);
newTR.id="a"+(++i);
addtable.parentNode.insertAdjacentElement("beforeEnd",newTR);
newTR.children[0].innerHTML=i;
}
function Delrow(){
var num = table1.rows.length;
if(num==2) return;
table1.deleteRow(table1.rows[num-1].rowIndex);
i--;
}
function ShortcutKey(){
if(window.event.keyCode==8)
Delrow();
if(window.event.keyCode==13)
Addrow();
}
document.onkeydown=ShortcutKey;
</script>