高手求助,动态添加删除控件!!
以下是我的原码!
想在表格内动态添加两个文本框,还要响应回车事件和其它事件。请高手写个代码吧!!!!!没有分了!!!
<script language=javascript src="date.js"></script>
<script language=javascript>
var c = new Calendar("c");
document.write(c);
function CheckForm()
{
if (document.myform.date1.value=="")
{alert("请选择一个有效日期!");
document.myform.date1.focus();
return false;}
if (document.myform.ks.value=="")
{alert("请选择科室!");
document.myform.ks.focus();
return false;}
if (document.myform.zyh.value=="")
{alert("请输入住院号!");
document.myform.zyh.focus();
return false;}
if (document.myform.xm.value=="")
{alert("请输入姓名!");
document.myform.xm.focus();
return false;}
}
function enterToTab()
{
if (window.event.keyCode==13)
{
window.event.keyCode=9;
}
}
</script>
<form method="POST" name="myform" onSubmit="return CheckForm();" action="Save.asp?flag=add" target="main">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr class="title">
<td height="22" align="center" colspan="4"><font size="4" color="#0033FF"><b>入院清单录入</b></font></td>
</tr>
<tr >
<td align="right">
<font color="#0033FF"> <strong>日期:</strong></font></td>
<td align="left"><input type="text" readonly name="date1" onFocus="c.showMoreDay = false;c.show(this);" size="10"></td>
<td align="right"><font color="#0033FF"><strong>请选择科室:</strong></font> </td>
<td align="left"><select size="1" name="ks">
<option value="1">科室1</option>
<option value="2">科室2</option>
</select>
</td>
</tr>
<tr>
<td colspan="4">
<table class="border" width="100%" id="testTbl">
<tr class="tdbg" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#BFDFFF'" height="25" id="tr1">
<td align="center" colspan="3" id="b">
<strong> 住院号:</strong>
<input type="text" name="zyh" onKeyDown="enterToTab()" size="10" onKeyUp="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" tabindex="1" id="txt1">
<strong>姓名:</strong>
<input type="text" name="xm" size="10" tabindex="2" onKeyDown="enterToTab()"></td> <td align="left">
<input type="button" name="button" id="add" value="增加一行" tabindex="3" onKeyDown="enterToTab()" onclick="addRow();"></td>
</tr>
</table>
</td>
</tr>
<tr align="center">
<td colspan="4">
<div align="center">
<p> </p>
<p>
<input name="Add" type="submit" id="Add" value=" 添 加 " onClick="document.myform.action='Save.asp?flag=add';document.myform.target='_self';" style="cursor:hand;" tabindex="40">
<input name="Cancel" type="button" id="Cancel" value=" 取 消 " onClick="history.go(-1)" style="cursor:hand;" tabindex="41">
</p>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
想要的效果和红字一样或者类似!!