<
html
>
< head ></ head >
< body >
< form >
< table width ='200px' align ="center" >
< thead >
< tr >< td width ='50%' > 货号 </ td >< td width ='50%' > 数量 </ td ></ tr >
</ thead >
< tbody id ='tbody' >
< tr >< td >< input type ="text" /></ td >< td >< input type ="text" onkeydown ="IsEnter(event)" /></ td ></ tr >
</ tbody >
< tfoot >
< tr >< td colspan ='2' align ="center" >< input type ="button" onclick ="return check(this.form)" value ="提交" /></ td ></ tr >
</ tfoot >
</ table >
< script type ="text/javascript" > ...
function IsEnter(e)
...{
e=e||event;
if(e.keyCode==13)
...{
NewRow();
//阻止提交的执行
if(e.preventDefault)//ff
e.prevetnDefault();
else//ie
...{
e.keyCode=0;
e.returnValue=false;
}
}
}
function NewRow()
...{
var td=document.getElementById('tbody');
td.appendChild(td.rows[0].cloneNode(true));
var inputs=td.rows[td.rows.length-1].getElementsByTagName("input");
for(var i=0;i<inputs.length;i++)
...{
inputs[i].value='';
}
inputs[0].focus();
}
function check(f)
...{
if(confirm('确认提交?'))
f.sumit();
}
</ script >
</ form >
</ body >
</ html >
< head ></ head >
< body >
< form >
< table width ='200px' align ="center" >
< thead >
< tr >< td width ='50%' > 货号 </ td >< td width ='50%' > 数量 </ td ></ tr >
</ thead >
< tbody id ='tbody' >
< tr >< td >< input type ="text" /></ td >< td >< input type ="text" onkeydown ="IsEnter(event)" /></ td ></ tr >
</ tbody >
< tfoot >
< tr >< td colspan ='2' align ="center" >< input type ="button" onclick ="return check(this.form)" value ="提交" /></ td ></ tr >
</ tfoot >
</ table >
< script type ="text/javascript" > ...
function IsEnter(e)
...{
e=e||event;
if(e.keyCode==13)
...{
NewRow();
//阻止提交的执行
if(e.preventDefault)//ff
e.prevetnDefault();
else//ie
...{
e.keyCode=0;
e.returnValue=false;
}
}
}
function NewRow()
...{
var td=document.getElementById('tbody');
td.appendChild(td.rows[0].cloneNode(true));
var inputs=td.rows[td.rows.length-1].getElementsByTagName("input");
for(var i=0;i<inputs.length;i++)
...{
inputs[i].value='';
}
inputs[0].focus();
}
function check(f)
...{
if(confirm('确认提交?'))
f.sumit();
}
</ script >
</ form >
</ body >
</ html >