try:
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function addRow() {
myTable.outerHTML=myTable.outerHTML.match(/(<[^>]*>)/)[0]+myTable.innerHTML+(myTable.rows[myTable.rows.length-1].outerHTML)+'</table>'
with(myTable.rows[myTable.rows.length-1]){
cells[0].innerText++;
cells[1].firstChild.value=Number(cells[1].firstChild.value)+100
cells[2].firstChild.value=Number(cells[2].firstChild.value)+100
}
}
function chkRowNum(){
var e=window.event.srcElement
var i=e.parentElement.cellIndex,r=e.parentElement.parentElement.rowIndex;
if(r==myTable.rows.length-1){addRow();myTable.rows[myTable.rows.length-2].cells[i].children[0].select();}
}
</SCRIPT></head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="98%" border="1" cellspacing="0" cellpadding="0" bordercolor="#ffcc00" align="center" id="myTable">
<th>n<th>开始<th>结束<th>价格</th>
<tr>
<td>1
<td><input type=text name=r1c1 size=20 onfocus="chkRowNum()" value=1>
<td><input type=text name=r1c2 size=20 value=100>
<td><input type=text name=r1c3 size=30>
</tr>
</table>
<input type=button onclick="addRow()" value=新增>
</form>
</body>
</html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function addRow() {
myTable.outerHTML=myTable.outerHTML.match(/(<[^>]*>)/)[0]+myTable.innerHTML+(myTable.rows[myTable.rows.length-1].outerHTML)+'</table>'
with(myTable.rows[myTable.rows.length-1]){
cells[0].innerText++;
cells[1].firstChild.value=Number(cells[1].firstChild.value)+100
cells[2].firstChild.value=Number(cells[2].firstChild.value)+100
}
}
function chkRowNum(){
var e=window.event.srcElement
var i=e.parentElement.cellIndex,r=e.parentElement.parentElement.rowIndex;
if(r==myTable.rows.length-1){addRow();myTable.rows[myTable.rows.length-2].cells[i].children[0].select();}
}
</SCRIPT></head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="98%" border="1" cellspacing="0" cellpadding="0" bordercolor="#ffcc00" align="center" id="myTable">
<th>n<th>开始<th>结束<th>价格</th>
<tr>
<td>1
<td><input type=text name=r1c1 size=20 onfocus="chkRowNum()" value=1>
<td><input type=text name=r1c2 size=20 value=100>
<td><input type=text name=r1c3 size=30>
</tr>
</table>
<input type=button onclick="addRow()" value=新增>
</form>
</body>
</html>
解决方案 »
- 如何给文本域设置焦点??
- 没学过JS,图片加载弱智问题
- 急急~~~~~js或者Jquery读取txt文件,(支持IE和火狐多种浏览器)!!!鸡鸡
- 求助:一个简单的javascript缓动问题
- 请大家介绍几个JavaScript学习网站
- 关于测试字符串不为空的困惑。(怎样才算真正不为空?)
- js中含有变量的replace怎么写的?
- 一个关于图片自动循环的JS,,新手上路,请前辈指点
- 怎么样用window.open()在同一个窗口打开新的页面?(急……)
- window.open('openwin.htm','newwin','fullscreen=yes,scrollbars=no');为什么滚动条还有?
- 如何在javascript中用submit传递中文的函数
- 关于execCommand('InsertImage',1)的问题,在线100分等候!
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--function button1_onclick() {
var i = document.all.uprange.length;
if (i==null)
{
i=1;
}
if (i==1)
{
var l = document.all.uprange.value;
}
else
var l = document.all.uprange[i-1].value;
if (l==""||isNaN(l))
{
l=0;
}else
l= parseFloat(l);l=l+1;var res ="";res+="<input type=\"text\" value="+l+" name=\"downrange\">到";
res +="<input type=\"text\" name=\"uprange\"> 价格";
res +="<input type=\"text\" name=\"unitprice\">";document.all.div1.innerHTML 2B=res;
}//-->
</SCRIPT>
</HEAD>
<BODY><P> </P>
<div id="div1">
<input type="text" name="downrange" value="1">到<input value="100" type="text" name="uprange"> 价格<input type="text" name="unitprice"></div>
<INPUT type="button" value="Add" id=button1 name=button1 LANGUAGE=javascript onclick="return button1_onclick()">
</BODY>
</HTML></慕白兄>