一个多行插入代码
<script language="javascript">
//输入脚本内容
function Max()
{
var str = (document.send.vii.value).length
alert ('输入值的长度为 ' + str + '位');
}
function changevalue()
{
if(document.all.vii.value == '' && document.all.vie.value != '')
{
document.all.vii.value = document.all.vie.value;
document.all.vie.value = '';
}
else if(document.all.vie.value == '' && document.all.vii.value != '')
{
document.all.vie.value = document.all.vii.value;
document.all.vii.value = '';
}
else if(document.all.vie.value != '' && document.all.vii.value != '')
{
var x = document.all.vie.value
var y = document.all.vii.value
document.all.vie.value = y;
document.all.vii.value = x;
}
}
</script>
<form name="send">
<input type=text value='' name="vii">
<input type=text value='' name="vie">
<input type="button" value="change" class="ButtonSave" onclick="javascript:changevalue();" id=button2 name=button2>
<input type="button" value="test" class="ButtonSave" onclick="javascript:Max();" id=button2 name=button2>
</form>
</br>
<script language="javascript">
<!--//一次性插入任意条记录
//增加单条
function setid(){
var d = (document.all.N.value)
str = '';
d = ++(d)
if(d>10)
{
alert('你真要把'+d+'行数据一次插入呀!\n可是系统最多只充许10行.')
return false;
}
for(i=1;i<=d;i++)
str+=''+i+'. 注册名:<input type=text name="name">密码:<input type=password name="pass"><br>';
window.tbid.innerHTML=str+'<br>';
if (d <= 10)
{
document.all.N.value = d ;
}
else
{document.all.N.value = 10}
document.all.upcount.value = 1;
document.all.scount.value = '';
//alert(str + '\nN的值为:' + document.all.N.value);
}
//批量增加
function batsetid()
{
str = ''
var d = document.all.upcount.value
if(d>10)
{
alert('你真要把'+d+'行数据一次插入呀!\n可是系统最多只充许10行.')
return false;
}
for(i=1;i<=d;i++)
str+=''+i+'. 注册名:<input type=text name="name">密码:<input type=password name="pass"><br>';
window.tbid.innerHTML=str+'<br>';
document.all.N.value = d ;
document.all.upcount.value = 1;
document.all.scount.value = '';
//alert(str + '\nN的值为:' + document.all.N.value);
}
//删除单条
function delline()
{
var d = document.all.N.value
str = '';
d = --(d)
if (d == 0)
{
alert('你真的一行都不想要了?');
//alert(d)
document.all.scount.value ='';
return false;
}
else if (d<0)
{
var x = document.all.scount.value;
var y = document.all.scount.value - document.all.N.value;
alert('要删除的条数'+x+'多于现有条数'+y+'条');
//alert(d);
document.all.scount.value ='';
return false;
}
for(i=1;i<=d;i++)
str+=''+i+'. 注册名:<input type=text name="name">密码:<input type=password name="pass"><br>';
window.tbid.innerHTML=str+'<br>';
document.all.N.value = d ;
document.all.scount.value = '';
}
//批量删除
function batdel()
{
if(document.all.scount.value == '')
{
alert('请输入要删除的条数!')
document.all.scount.focus();
return false;
}
str = ''
var d = document.all.N.value
d = d - document.all.scount.value
if (d == 0)
{
alert('你真的一行都不想要了?');
//alert(d)
document.all.scount.value ='';
return false;
}
else if (d<0)
{
var x = document.all.scount.value;
var y = document.all.scount.value - document.all.N.value;
alert('要删除的条数'+x+'多于现有条数'+y+'条');
//alert(d);
document.all.scount.value ='';
return false;
}
for(i=1;i<=d;i++)
str+=''+i+'. 注册名:<input type=text name="name">密码:<input type=password name="pass"><br>';
window.tbid.innerHTML=str+'<br>';
document.all.pass.focus();
document.all.N.value = d ;
document.all.upcount.value = 1;
document.all.scount.value = '';
//alert(str + '\nN的值为:' + document.all.N.value);
}
//-->
</script>
<script for="document" event="onkeydown" language="javascript">
//键盘操作定义,允许一路回车进行到底.
if (event.keyCode==13){
event.keyCode = 9;
}
if (event.keyCode == 187)
{
setid();
}
if (event.keyCode == 189)
{
delline();
}
if (event.ctrlKey)
{
if(event.keyCode == 46)
{
document.all.scount.value = document.all.N.value - 1
if (confirm('确定要删除吗?'))
{batdel();}
}
if(event.keyCode == 45)
{
document.all.upcount.value = 10
batsetid();
}
}
</script>
<body onload="document.all.pass.focus();">
<form name="myform" >
<select name="upcount" class="txtfld4" onChange="batsetid()">
<option value="1">1 条</option>
<option value="2">2 条</option>
<option value="3">3 条</option>
<option value="4">4 条</option>
<option value="5">5 条</option>
<option value="6">6 条</option>
<option value="7">7 条</option>
<option value="8">8 条</option>
<option value="9">9 条</option>
<option value="10">10 条</option>
</select>
减少数量 <input type="text" name="scount" value= "" size="3" maxlength="2"><input type="button" value="BatchDel-" class="ButtonSave" onclick="javascript:batdel();" id=button2 name=button2><input type="button" value="Add+" class="ButtonSave" onclick="javascript:setid();" id=button2 name=button2><input type="button" value="Del-" class="ButtonSave" onclick="javascript:delline();" id=button2 name=button2>
<TABLE>
<TR >
<TD id="tbid" colspan="3" nowrap>用户名<input type=text name="name">
密码<input type=password name="pass">
<br></td>
</TR>
</TABLE>
当前数量:<INPUT TYPE="text" name="N" value="1">
</form>
+号增加行 -号减少行 Ctrl+Del删除所有 Ctrl+ins加到最多
</body>