H
haoshan
Unregistered / Unconfirmed
GUEST, unregistred user!
现在的问题是,可以增加一行,但不能删除,前十行中前三个是级连的选择框,但增加的行级连菜单就实现不了.我找了好几天也没找道到错误在哪,请大家帮忙!
<html>
<head>
<title>Untitleddo
cument</title>
<meta http-equiv="Content-Type"
content="text/html;
charset=gb2312">
</head>
<script language="JavaScript"
src="sy/blc_zm.js"
type="text/JavaScript"></script>
<SCRIPT language=javascript>
var line=2
function delIt()
{
line=parseInt(event.srcElement.ln,10)
if (line>0)
for (i=1;i<PLList.rows.length;i++)
if (tdt.ln==line)
{
if (do
cument.ecform.medication.value.length>0 )
if (!confirm("Are you sure you want to delete this record?")
return
PLList.deleteRow(i)
}
}
function mouseOver()
{
event.srcElement.className="delMouseOver"
}
function mouseOut()
{
event.srcElement.className="scheduleButtonVisible"
}
</script>
<body bgcolor="#FFFFFF"
text="#000000">
<form action=sy/save_insert_del.asp method ="POST"
name="frm"
style="border-style: solid;
border-width: 1px;
padding-left: 4px;
padding-right: 4px;
padding-top: 1px;
padding-bottom: 1px">
<TABLE id=fileinput0 width="876"
bgcolor="#DDEEFF">
<tr>
<td width="9%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">类别</td>
<td width="11%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">物资名称</td>
<td width="11%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">规格型号</td>
<td width="9%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">计量单位</td>
<td width="9%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">税率</td>
<td width="11%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">数量</td>
<td width="9%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">不含税单价</td>
<td width="13%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">含税金额</td>
<td width="13%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">税额</td>
<td width="5%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">删除</td>
</tr>
</TABLE>
<% for i=0 to 9 %>
<table id=fileinput<%=i+1%> width="877"
bgcolor="#DDEEFF">
<tr>
<td width="9%"
bordercolor="#FFFFFF">
<select name=lb style="WIDTH:75;
height:19"
onchange="MulSelect(1,<%=i%>)"
tabindex="<%=i+2%>"></select></td>
<td bgcolor="#FFFFFF"
width="10%"
bordercolor="#FFFFFF">
<select name=sname style="WIDTH:90;
height:19"
onchange="MulSelect(2,<%=i%>)"
tabindex="<%=i+2%>"></select></td>
<td bgcolor="#FFFFFF"
width="10%"
bordercolor="#FFFFFF">
<select name=ggxh style="WIDTH:91;
height:19"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></select></td>
<td bgcolor="#FFFFFF"
width="8%"
bordercolor="#FFFFFF">
<input type="text"
name="a4"
size="10"
style="border=0;"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="9%"
bordercolor="#FFFFFF">
<input type="text"
name="a5"
size="10"
style="border=0;"
onKeypress="return (/[/d.]/.test(String.fromCharCode(event.keyCode)))"
onchange=get(<%=i%>) onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="10%"
bordercolor="#FFFFFF">
<input type="text"
name="a6"
size="12"
style="border=0;"
onchange=get(<%=i%>) onKeypress="
if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="9%"
bordercolor="#FFFFFF"><input type="text"
name="a7"
size="10"
style="border=0;"
onchange=get(<%=i%>) tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="12%"
bordercolor="#FFFFFF"><input type="text"
name="a8"
size="14"
style="border=0;"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="13%"
bordercolor="#FFFFFF"><input type="text"
name="a9"
size="14"
style="border=0;"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="5%"
bordercolor="#FFFFFF"><input type=button value=删除 class=cbutton OnClick="DelFileInput(<%=i+1%>)"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
</tr>
</TABLE>
<% next %>
<input type="button"
name="add_line"
value="增加下一行"
OnClick="AddFileInput()"
onkeydown="return tabclick()">
<script language="VBScript">
NowFileInputNo = 11
NowFileInputCount =10
idx=12
Sub AddFileInput()
HTMLSrc = "<table id=fileinput"&NowFileInputNo&"
width=""877""
bgcolor=""#DDEEFF""><tr> <td width=""9%""
bordercolor=""#FFFFFF""><select name=lb style=""WIDTH:75;
height:19""
onchange=""MulSelect(1,"&NowFileInputCount&"""
tabindex="""&idx&"""></select></td><td bgcolor=""#FFFFFF""
width=""10%""
bordercolor=""#FFFFFF""><select name=sname style=""WIDTH:90;
height:19""
onchange=""MulSelect(2,"&NowFileInputCount&"""
tabindex="""&idx&"""></select></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""10%""
bordercolor=""#FFFFFF""><select name=ggxh style=""WIDTH:91;
height:19""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></select></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""8%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a4""
size=""10""
style=""border=0;""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></td><td bgcolor=""#FFFFFF""
width=""9%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a5""
size=""10""
style=""border=0;""
onKeypress=""return (/[/d.]/.test(String.fromCharCode(event.keyCode)))""
onchange=get("&NowFileInputCount&" onkeydown=""return tabclick()""
tabindex="""&idx&"""></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""10%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a6""
size=""12""
style=""border=0;""
onchange=get("&NowFileInputCount&" onKeypress=""
if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;""
onkeydown=""return tabclick()""
tabindex="&idx&"></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""9%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a7""
size=""10""
style=""border=0;""
onchange=get("&NowFileInputCount&" tabindex="""&idx&"""></td><td bgcolor=""#FFFFFF""
width=""12%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a8""
size=""14""
style=""border=0;""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""13%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a9""
size=""14""
style=""border=0;""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></td><td bgcolor=""#FFFFFF""
width=""5%""
bordercolor=""#FFFFFF""><input type=button value=删除 class=cbutton OnClick=""DelFileInput("&NowFileInputNo&"""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></td></tr></TABLE>"
HTMLSrc = HTMLSrc &
vbcrlf
do
cument.all.add_line.InsertAdjacentHTML "beforebegin
", HTMLSrc
Call MulSelect(0,NowFileInputCount)
idx=idx+1
NowFileInputNo = NowFileInputNo + 1
NowFileInputCount = NowFileInputCount + 1
End Sub
Sub DelFileInput(tableno)
do
cument.all("FileInput"&
tableno).outerHTML = ""
NowFileInputCount = NowFileInputCount - 1
End Sub
</script>
<script>
// 三级联动
var arrSel=["lb","sname","ggxh"]
arrData=[];
// 从数据库中读出三级联动的数据, 保存到 arrData 数组中(二维数组)
<%
dim conn,rs
set conn = Server.CreateObject("ADODB.Connection"
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
&
Server.mappath("rktz/rktz.mdb" &
";Persist Security Info=False"
set rs=conn.execute("select * from spxx"
do while not rs.eof
%>
arrData[arrData.length]=["<%=trim(rs("lb")%>","<%=trim(rs("sname")%>","<%=trim(rs("ggxh")%>"]
<%
rs.movenext
loop
rs.close:set rs=nothing
conn.close:set conn=nothing
%>
</script>
<script language=javascript >
//单价金额的级连函数
function get(h){
var m;
m=document.all.a5(h).value;
document.all.a8(h).value=document.all.a7(h).value*m*document.all.a6(h).value;
m=m-1;
document.all.a9(h).value=document.all.a7(h).value*m*document.all.a6(h).value}
function tabclick() {
if (window.event.keyCode==13) {
window.event.keyCode=9
}
}
// 下拉框选择变化时触发的函数,用于重新生成其下级下拉框
// num : 下拉框的级数, 1 表示最顶级
function MulSelect(num,k)
{
var i,j,arrTemp=[];
// 取得表单当前触发的下拉框的父级下拉框的值, 存放于 arrTemp 数组中(即不需要改变的值)
for(i=0;i<num;i++)
{
arrTemp=eval("document.frm."+arrSel)(k).value
}
if(num<arrSel.length)
{
// 对于触发下拉框的下一级的下拉框
with(eval("document.frm."+arrSel[num])(k))
{
// 先清空内容
length=0
// 对所有的记录遍历
for(i=0;i<arrData.length;i++)
{
var find=false
// 如果父级下拉框的记录不是当前选中的值,则跳过
for(j=0;j<num;j++)
{
if(arrTemp[j]!=arrData[j])
{
break;
}
}
if(j!=num)
{
continue;
}
// 这里已经可以保证第 i 项记录的数据属于当前选项的子数据
// 检查循环过程中是否已经添加了该选项,如果已有了, 则 fine = true
for(m=0;m<options.length;m++)
{
if(options[m].text==arrData[num])
{
find=true
}
}
// 若当前没有选项或者尚未添加该选项项,则添加之
if(length==0||!find)
{
options[options.length]=new Option(arrData[num],arrData[num])
}
}
// 递归调用生成下一级菜单的内容
MulSelect((num+1),k)
}
}
MulSelect(0,k+1)}
// 调用联动函数初始化下拉框
MulSelect(0,0)
</script>
<p><input type="submit"
value="提交"
name="B1"><input type="reset"
value="重置"
name="B2"></p>
</form>
</body>
</html>
<html>
<head>
<title>Untitleddo
cument</title>
<meta http-equiv="Content-Type"
content="text/html;
charset=gb2312">
</head>
<script language="JavaScript"
src="sy/blc_zm.js"
type="text/JavaScript"></script>
<SCRIPT language=javascript>
var line=2
function delIt()
{
line=parseInt(event.srcElement.ln,10)
if (line>0)
for (i=1;i<PLList.rows.length;i++)
if (tdt.ln==line)
{
if (do
cument.ecform.medication.value.length>0 )
if (!confirm("Are you sure you want to delete this record?")
return
PLList.deleteRow(i)
}
}
function mouseOver()
{
event.srcElement.className="delMouseOver"
}
function mouseOut()
{
event.srcElement.className="scheduleButtonVisible"
}
</script>
<body bgcolor="#FFFFFF"
text="#000000">
<form action=sy/save_insert_del.asp method ="POST"
name="frm"
style="border-style: solid;
border-width: 1px;
padding-left: 4px;
padding-right: 4px;
padding-top: 1px;
padding-bottom: 1px">
<TABLE id=fileinput0 width="876"
bgcolor="#DDEEFF">
<tr>
<td width="9%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">类别</td>
<td width="11%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">物资名称</td>
<td width="11%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">规格型号</td>
<td width="9%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">计量单位</td>
<td width="9%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">税率</td>
<td width="11%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">数量</td>
<td width="9%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">不含税单价</td>
<td width="13%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">含税金额</td>
<td width="13%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">税额</td>
<td width="5%"
style="border-style: solid;
border-width: 1px"
bgcolor="#FFFFFF">
<p align="center">删除</td>
</tr>
</TABLE>
<% for i=0 to 9 %>
<table id=fileinput<%=i+1%> width="877"
bgcolor="#DDEEFF">
<tr>
<td width="9%"
bordercolor="#FFFFFF">
<select name=lb style="WIDTH:75;
height:19"
onchange="MulSelect(1,<%=i%>)"
tabindex="<%=i+2%>"></select></td>
<td bgcolor="#FFFFFF"
width="10%"
bordercolor="#FFFFFF">
<select name=sname style="WIDTH:90;
height:19"
onchange="MulSelect(2,<%=i%>)"
tabindex="<%=i+2%>"></select></td>
<td bgcolor="#FFFFFF"
width="10%"
bordercolor="#FFFFFF">
<select name=ggxh style="WIDTH:91;
height:19"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></select></td>
<td bgcolor="#FFFFFF"
width="8%"
bordercolor="#FFFFFF">
<input type="text"
name="a4"
size="10"
style="border=0;"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="9%"
bordercolor="#FFFFFF">
<input type="text"
name="a5"
size="10"
style="border=0;"
onKeypress="return (/[/d.]/.test(String.fromCharCode(event.keyCode)))"
onchange=get(<%=i%>) onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="10%"
bordercolor="#FFFFFF">
<input type="text"
name="a6"
size="12"
style="border=0;"
onchange=get(<%=i%>) onKeypress="
if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="9%"
bordercolor="#FFFFFF"><input type="text"
name="a7"
size="10"
style="border=0;"
onchange=get(<%=i%>) tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="12%"
bordercolor="#FFFFFF"><input type="text"
name="a8"
size="14"
style="border=0;"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="13%"
bordercolor="#FFFFFF"><input type="text"
name="a9"
size="14"
style="border=0;"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
<td bgcolor="#FFFFFF"
width="5%"
bordercolor="#FFFFFF"><input type=button value=删除 class=cbutton OnClick="DelFileInput(<%=i+1%>)"
onkeydown="return tabclick()"
tabindex="<%=i+2%>"></td>
</tr>
</TABLE>
<% next %>
<input type="button"
name="add_line"
value="增加下一行"
OnClick="AddFileInput()"
onkeydown="return tabclick()">
<script language="VBScript">
NowFileInputNo = 11
NowFileInputCount =10
idx=12
Sub AddFileInput()
HTMLSrc = "<table id=fileinput"&NowFileInputNo&"
width=""877""
bgcolor=""#DDEEFF""><tr> <td width=""9%""
bordercolor=""#FFFFFF""><select name=lb style=""WIDTH:75;
height:19""
onchange=""MulSelect(1,"&NowFileInputCount&"""
tabindex="""&idx&"""></select></td><td bgcolor=""#FFFFFF""
width=""10%""
bordercolor=""#FFFFFF""><select name=sname style=""WIDTH:90;
height:19""
onchange=""MulSelect(2,"&NowFileInputCount&"""
tabindex="""&idx&"""></select></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""10%""
bordercolor=""#FFFFFF""><select name=ggxh style=""WIDTH:91;
height:19""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></select></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""8%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a4""
size=""10""
style=""border=0;""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></td><td bgcolor=""#FFFFFF""
width=""9%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a5""
size=""10""
style=""border=0;""
onKeypress=""return (/[/d.]/.test(String.fromCharCode(event.keyCode)))""
onchange=get("&NowFileInputCount&" onkeydown=""return tabclick()""
tabindex="""&idx&"""></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""10%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a6""
size=""12""
style=""border=0;""
onchange=get("&NowFileInputCount&" onKeypress=""
if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;""
onkeydown=""return tabclick()""
tabindex="&idx&"></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""9%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a7""
size=""10""
style=""border=0;""
onchange=get("&NowFileInputCount&" tabindex="""&idx&"""></td><td bgcolor=""#FFFFFF""
width=""12%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a8""
size=""14""
style=""border=0;""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></td>"
HTMLSrc = HTMLSrc &"<td bgcolor=""#FFFFFF""
width=""13%""
bordercolor=""#FFFFFF""><input type=""text""
name=""a9""
size=""14""
style=""border=0;""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></td><td bgcolor=""#FFFFFF""
width=""5%""
bordercolor=""#FFFFFF""><input type=button value=删除 class=cbutton OnClick=""DelFileInput("&NowFileInputNo&"""
onkeydown=""return tabclick()""
tabindex="""&idx&"""></td></tr></TABLE>"
HTMLSrc = HTMLSrc &
vbcrlf
do
cument.all.add_line.InsertAdjacentHTML "beforebegin
", HTMLSrc
Call MulSelect(0,NowFileInputCount)
idx=idx+1
NowFileInputNo = NowFileInputNo + 1
NowFileInputCount = NowFileInputCount + 1
End Sub
Sub DelFileInput(tableno)
do
cument.all("FileInput"&
tableno).outerHTML = ""
NowFileInputCount = NowFileInputCount - 1
End Sub
</script>
<script>
// 三级联动
var arrSel=["lb","sname","ggxh"]
arrData=[];
// 从数据库中读出三级联动的数据, 保存到 arrData 数组中(二维数组)
<%
dim conn,rs
set conn = Server.CreateObject("ADODB.Connection"
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
&
Server.mappath("rktz/rktz.mdb" &
";Persist Security Info=False"
set rs=conn.execute("select * from spxx"
do while not rs.eof
%>
arrData[arrData.length]=["<%=trim(rs("lb")%>","<%=trim(rs("sname")%>","<%=trim(rs("ggxh")%>"]
<%
rs.movenext
loop
rs.close:set rs=nothing
conn.close:set conn=nothing
%>
</script>
<script language=javascript >
//单价金额的级连函数
function get(h){
var m;
m=document.all.a5(h).value;
document.all.a8(h).value=document.all.a7(h).value*m*document.all.a6(h).value;
m=m-1;
document.all.a9(h).value=document.all.a7(h).value*m*document.all.a6(h).value}
function tabclick() {
if (window.event.keyCode==13) {
window.event.keyCode=9
}
}
// 下拉框选择变化时触发的函数,用于重新生成其下级下拉框
// num : 下拉框的级数, 1 表示最顶级
function MulSelect(num,k)
{
var i,j,arrTemp=[];
// 取得表单当前触发的下拉框的父级下拉框的值, 存放于 arrTemp 数组中(即不需要改变的值)
for(i=0;i<num;i++)
{
arrTemp=eval("document.frm."+arrSel)(k).value
}
if(num<arrSel.length)
{
// 对于触发下拉框的下一级的下拉框
with(eval("document.frm."+arrSel[num])(k))
{
// 先清空内容
length=0
// 对所有的记录遍历
for(i=0;i<arrData.length;i++)
{
var find=false
// 如果父级下拉框的记录不是当前选中的值,则跳过
for(j=0;j<num;j++)
{
if(arrTemp[j]!=arrData[j])
{
break;
}
}
if(j!=num)
{
continue;
}
// 这里已经可以保证第 i 项记录的数据属于当前选项的子数据
// 检查循环过程中是否已经添加了该选项,如果已有了, 则 fine = true
for(m=0;m<options.length;m++)
{
if(options[m].text==arrData[num])
{
find=true
}
}
// 若当前没有选项或者尚未添加该选项项,则添加之
if(length==0||!find)
{
options[options.length]=new Option(arrData[num],arrData[num])
}
}
// 递归调用生成下一级菜单的内容
MulSelect((num+1),k)
}
}
MulSelect(0,k+1)}
// 调用联动函数初始化下拉框
MulSelect(0,0)
</script>
<p><input type="submit"
value="提交"
name="B1"><input type="reset"
value="重置"
name="B2"></p>
</form>
</body>
</html>