javascrip部分<script for="document" event="onkeydown" language="javascript"> str=new String(event.srcElement.name); var strex; var sss; var nRowNumber; if (event.keyCode==13) { if (str.substring(0,5)=="Pcode") { .......................... } } else if (event.keyCode==38) //向上键 { if ((str.substring(0,5)=="Pcode") && (eval(str.substring(5,7))>1)) document.all["Pcode"+(eval(str.substring(5,7))-1)].focus(); ........................................ } else if (event.keyCode==40) //向下键 { if ((str.substring(0,5)=="Pcode") && (eval(str.substring(5,7))<nRowCount)) document.all["Pcode"+(eval(str.substring(5,7))+1)].focus(); ................................... } ...........................................
</script> <SCRIPT LANGUAGE=javascript> <!-- var nRowCount; var nRecordCount nRowCount="10"; nRecordCount="10"; function AddRow() { var ob; var orow,ocell; var v,r; var ca1,ca2,ca3; ca1="this.style.background='#F3FDE3'"; ca2="this.style.background='#ffffff'"; ca3="javascript:nRowNumber=ch"; ob=grid; orow=ob.insertRow(eval(nRowCount)+1); nRowCount=eval(nRowCount)+1; orow.id="Row"+nRowCount; orow.name="Row"+nRowCount; orow.className ="ClientTablerow";
function check(){
document.form1.all.value=(document.form1.num.value)*(document.form1.every.value);
}
</script>
<form name="form1">
个数:<input name="num" type="txt" value=0 onkeyup="value=value.replace(/[^\d]/g,'');check();">
单价:<input name="every" type="txt" value=0 onkeyup="value=value.replace(/[^\d]/g,'');check();">
总计:<input name="all" type="txt" value=0 disabled>
</form>
取掉
<table width="100%" ID="grid" width="100%" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#E6EBF2" bordercolordark="#F4FFF0" nowrap>
<tr class="ListTableHeader2" align="center" height="20px">
<td nowrap width="4%">No.</td>
<td nowrap width="14%">编号</td>
<td nowrap width="20%">名称</td>
<td nowrap width="10%">规格</td>
<td nowrap width="10%">类型</td>
<td nowrap width="10%">件数</td>
<td nowrap width="10%">重量</td>
<td nowrap width="10%">体积</td>
<td nowrap width="16%">到达</td>
<td nowrap width="2%"></td>
</tr>
<script LANGUAGE="javascript">
var nRowNumber; //焦点所在行
var nRecordCount; //已经有数据的行数
var nRowCount; //总的行数
nRecordCount=0;
nRowNumber=0;
nRowCount=10;
</script>
<tr class="ClientTablerow" bgColor="#FDFCF7" name="Row1" id="Row1">
<td nowrap bgcolor="#ffffff"> 1
<input name="PBillID1" type="hidden" size=3></td>
<td nowrap align="left"><input ch="1" type="text" class="flateditbox-2" name="Pcode1" style="width:120px;background:'#ffffff'" onFocus="this.style.background='#F3FDE3'" onBlur="this.style.background='#ffffff'" onkeydown="javascript:nRowNumber=ch"></td>
<td nowrap align="left"><input ch="1" disabled=false type="text" class="flateditbox-2" name="Pname1" style="width:160px;background:'#ffffff'" onFocus="this.style.background='#F3FDE3'" onBlur="this.style.background='#ffffff'" onkeydown="javascript:nRowNumber=ch"></td>
<td nowrap align="left" ><input name="Pstand1" type="text" class="flateditbox-2" style="width:80px;background:'#ffffff'" onFocus="this.style.background='#F3FDE3';" onBlur="this.style.background='#ffffff';" onkeydown="javascript:nRowNumber=ch" ch="1"></td>
<td nowrap align="left" ><input name="Ptype1" type="text" class="flateditbox-2" style="width:80px;background:'#ffffff'" onFocus="this.style.background='#F3FDE3';" onBlur="this.style.background='#ffffff';" onKeyDown="javascript:nRowNumber=ch" ch="1"></td>
<td nowrap align="left" ><input name="Ppiece1" disabled=false type="text" class="flateditbox-2" style="width:80px;background:'#ffffff'" onFocus="this.style.background='#F3FDE3';" onBlur="this.style.background='#ffffff';" onkeydown="javascript:nRowNumber=ch" ch="1"></td>
<td nowrap align="left" ><input name="Pweight1" disabled=false type="text" class="flateditbox-2" style="width:80px;background:'#ffffff'" onFocus="this.style.background='#F3FDE3';" onBlur="this.style.background='#ffffff';" onkeydown="javascript:nRowNumber=ch" ch="1"></td>
<td nowrap align="left" ><input name="Pspace1" disabled=false type="text" class="flateditbox-2" style="width:80px;background:'#ffffff'" onFocus="this.style.background='#F3FDE3';" onBlur="this.style.background='#ffffff';" onKeyDown="javascript:nRowNumber=ch" ch="1"></td>
<td nowrap align="left"><input name="Parea1" disabled=false type="text" class="flateditbox-2" style="width:80px;background:'#ffffff'" onFocus="this.style.background='#F3FDE3';" onBlur="this.style.background='#ffffff';" onKeyDown="javascript:nRowNumber=ch" ch="1"></td>
<td nowrap title="删除本行"><img ch="1" src="../images/IconDelete.gif" onmouseover="src='../images/IconDelete.gif'" onmouseout="src='../images/IconDelete.gif'" onclick="nRowNumber=ch;DeleteRow(ch)" WIDTH="16" HEIGHT="16"></td>
</tr>
<tr class="Tablesum" height="20px">
<td colspan="5" height="20">合计</td>
<td nowrap align="left" id="AllCheckQty"> </td>
<td nowrap align="left" id="AllCheckQty"> </td>
<td nowrap align="left" id="AllCheckQty"> </td>
<td nowrap align="left" id="AllCountQty"> </td>
<td nowrap align="right"> </td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
str=new String(event.srcElement.name);
var strex;
var sss;
var nRowNumber; if (event.keyCode==13)
{
if (str.substring(0,5)=="Pcode")
{
..........................
}
}
else if (event.keyCode==38) //向上键
{
if ((str.substring(0,5)=="Pcode") && (eval(str.substring(5,7))>1))
document.all["Pcode"+(eval(str.substring(5,7))-1)].focus();
........................................
}
else if (event.keyCode==40) //向下键
{
if ((str.substring(0,5)=="Pcode") && (eval(str.substring(5,7))<nRowCount))
document.all["Pcode"+(eval(str.substring(5,7))+1)].focus();
...................................
}
...........................................
</script>
<SCRIPT LANGUAGE=javascript>
<!--
var nRowCount;
var nRecordCount
nRowCount="10";
nRecordCount="10"; function AddRow()
{
var ob;
var orow,ocell;
var v,r;
var ca1,ca2,ca3;
ca1="this.style.background='#F3FDE3'";
ca2="this.style.background='#ffffff'";
ca3="javascript:nRowNumber=ch";
ob=grid;
orow=ob.insertRow(eval(nRowCount)+1);
nRowCount=eval(nRowCount)+1;
orow.id="Row"+nRowCount;
orow.name="Row"+nRowCount;
orow.className ="ClientTablerow";
for(var i=0;i<10;i++)
{
ocell=orow.insertCell();
ocell.bgColor="#ffffff";
if (i==0) //跳过第一列
{
ocell.innerHTML=" "+nRowCount+"<input type='hidden' size=2 name='PBillID"+nRowCount+"'>";
} //序号列
else if (i==1)
{
ocell.innerHTML="<input ch="+nRowCount+" type='text' class='flateditbox-2' name="+"Pcode"+nRowCount+" style='width:120px;background:#ffffff' onFocus="+ca1+" onBlur="+ca2+" onkeydown="+ca3+">";
}
....................................................
else if (i==9)
{
ca1="this.src='../images/IconDelete.gif'";
ca2="this.src='../images/IconDelete.gif'";
ca3="DeleteRow("+nRowCount+")";
ocell.innerHTML="<img src='../images/IconDelete.gif' width='16' height='16' onmouseover="+ca1+" onmouseout="+ca2+" onclick="+ca3+">";
ocell.title="删除本行";
}
}
}function DeleteRow(currow)
{
var ob;
if (nRowCount==0) return false;
ob=grid;
if (confirm('您确定要删除本行信息吗?')){
if (currow<=nRecordCount)
nRecordCount=eval(nRecordCount)-1;
if (currow==nRowCount)
{
ob.deleteRow(ob.rows("Row"+currow).rowIndex);
nRowCount=eval(nRowCount)-1;
}
else
{
for(var i=currow;i<=eval(nRowCount);i++)
{
if (i==nRowCount)
{
ob.deleteRow(ob.rows("Row"+nRowCount).rowIndex);
nRowCount=eval(nRowCount)-1;
}
else
{
document.all["PBillID"+i].value=document.all["PBillID"+(eval(i)+1)].value;
........................................................
}
} }
}
}
-->
</script>