<html>
<head>
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META name=VI60_defaultClientScript content=VBScript>
<link rel="stylesheet" type="text/css" href="VbsCode\Css\Style.css" title="styles"><style>
.textarea {behavior:url(VbsCode/Htc/textarea.htc);overflow-y:auto;}
.FontHtc {behavior:url(VbsCode/Htc/Font.htc);}
</style>
<title>龙大集团办公网</title>
</head>
<SCRIPT language=VBScript>
Dim RowNum,RowCount
Sub AddItem_Onclick()
InserItem RowNum +2
End SubSub InserNew(RowId)
InserItem RowId.rowIndex
End SubSub InserItem(Num)
Dim II
Dim myNewRow,myNewCell
RowCount=RowCount+1 '总数加一;始终加一
RowNum=RowNum+1 '总数加一;为了增加准备,动态的改变
Set myNewRow = Form.All.myTable.insertRow(Num)
myNewRow.bgcolor= "gainsboro"
myNewRow.Id="Row" & CStr(RowCount)
myNewRow.Align="Center"
For II=0 To 3
Set myNewCell=myNewRow.insertcell()
Select case II
Case 0:
myNewCell.innerHTML ="<input type='checkbox' Onclick='DeleteRow CancelInfo" & RowCount & ",Row" & CStr(RowCount) & "' Id='CancelInfo" & RowCount & "' name='CancelInfo" & RowCount & "' value='ON'>"
Case 1:
myNewCell.innerHTML ="<input Id='SSMStepName" & RowNum & "' name='SSMStepName' MaxLength='10' size='14' Value='' Style='border-style: groove;'>"
Case 2:
myNewCell.innerHTML ="<textarea class='textarea' DefaultHeight=80 MaxHeight=200 rows='5' style='BORDER-STYLE: groove;' Id='CCMUserInfo" & RowCount & "' Name='SSMUserInfo' cols='25' ReadOnly></textarea><INPUT Onclick='ChoosePerson CCMUserInfo" & CStr(RowCount) & ",SSNUserInfo" & CStr(RowCount) & "' id=button" & RowNum & " type=button value='...' name=MyButton Title=''选择人员><textarea style='BORDER-STYLE: groove;' Id='SSNUserInfo" & RowCount & "' Name='SSNUserInfo' cols='25' ReadOnly Style='Display:None'></textarea>"
Case 3:
myNewRow.Align="Center"
myNewCell.innerHTML ="<img border='0' Style='Cursor:Hand' Id='Pic" & RowCount & "' Onclick='InserNew Row" & CStr(RowCount) & "' src='Images/Jyl016.gif' width='16' height='16' Alt='插入新行'>"
End Select
Next
End SubSub DeleteRow(CId,RowId)
Dim M
Dim myRow,myCell
M=Msgbox("真的要删除么",VbYesNo,"请确认")
If M=VbNo Then
CId.Checked=False
Exit Sub
End If
myTable.deleteRow(RowId.rowIndex)
RowNum=RowNum-1 '总数减一
End Sub
Sub Kill()
Dim M
M=Msgbox("真的要删除此流程么",VbYesNo,"请确认")
If M=VbNo Then
Exit Sub
End If
Form.BackKill.Value="True"
Form.Submit
End Sub
Sub CFlow_Onchange()
Form.action="SystemPage.Asp?WCI=DepartFlow&WCE=Main"
Form.Submit
End Sub
Dim Re,II
Re = ShowModalDialog("SystemPage.Asp?WCI=ChoosePerson&WCE=" & PersonId.Value, "PersonInfo" ,"dialogwidth:45 ; dialogheight:26")
If Re="" Then Exit Sub
II=inStr(Re,"//")
If II > 0 Then
'Form.PersonCode.Value=Left(Re,II-1)
Re=Right(Re,Len(Re)-II-1)
II=inStr(Re,"//")
If II > 0 Then
'Form.PersonName.Value=Left(Re,II-1)
Re=Right(Re,Len(Re)-II-1)
II=inStr(Re,"//")
If II > 0 Then
PersonId.Value=Left(Re,II-1)
PersonInfo.Value=Right(Re,Len(Re)-II-1)
End If
End If
End If
End Sub
</SCRIPT>
<SCRIPT language=vbscript>Sub SButton()
Dim sItem,MS
For Each sItem In Form.All
If Mid(sItem.ID,3,1)="M" Then
If sItem.Value="" Then
Msgbox "必添项目不得为空"
sItem.Focus
Exit Sub
End If
End IfSelect Case left(sItem.ID, 2)
Case "SS"
If CheckString(Trim(sItem.value)) <> "" Then
MsgBox "字符型内不得包含""*&'/?_%<>()[]等字符",vbExclamation
sItem.Focus
Exit sub
End if
sItem.Value=Trim(sItem.Value)
Case "NN"
If IsNumeric(sItem.Value)=False Then
Msgbox "请输入数字型信息"
sItem.Focus
Exit sub
Else
if sItem.Value>=99999999999 Then
Msgbox "数据过大"
sItem.Focus
Exit Sub
End if
End if
sItem.Value=Trim(sItem.Value)
Case "DD"
If IsDate(sItem.Value)=False Then
Msgbox "请根据情况输入:" & vbCrLf & "日期型[2001-12-12]/时间型[12:12]/综合型[2001-12-12 12:12]信息"
sItem.Focus
Exit sub
End if
sItem.Value=Trim(sItem.Value)
Case "FF"
If instr(sItem.Value,".") <> 0 Then
FileName=right(sItem.Value,Len(sItem.Value)-instr(sItem.Value,"."))
Select Case lcase(FileName)
Case "--------------"
Msgbox "文件类型不能上传--------------等格式"
sItem.Focus
Exit Sub
Case Else
End Select
End If
End Select
Next
Form.Submit
End SubFunction CheckString(ByVal sSource)
Dim ii, cc, nn, css
css = """*&'/?_%<>()[]"
nn = Len(sSource)
For ii = 1 To nn
cc = Mid(sSource, ii, 1)
If InStr(1, css, cc) > 0 Then
CheckString = css
Exit Function
End If
Next
CheckString = ""
End Function
</SCRIPT>
<body style="background-color: #EDF1F8">
<form Id=Form method="post" action="SystemPage.Asp?WCI=DepartFlow&WCE=Edit">
<table border="0" width="90%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" align="center"><img border="0" src="Images/MainMenu/DepartFlow.gif" width="25" height="25" align=absmiddle> <font Style="Font-Size=16px">部门流程</font><Br><Br></td>
<center>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" width="90%" cellspacing="0" cellpadding="0">
<tr>
<td width="40%">选择流程:
<select size="1" Id=CFlow name="CFlow">
<option value="">新流程</option>
<option value="asd">asd</option></select></td>
<td width="60%" align=right>
流程名称:<INPUT id=SSMFlowName name=SSMFlowName size="15" onmouseover="window.event.srcElement.focus" onfocus="window.event.srcElement.select" Value="" style="BORDER-LEFT: 0px; BORDER-RIGHT: 0px; BORDER-TOP: 0px;text-align: right;BACKGROUND-COLOR: #EDF1F8;" MaxLength=50>
</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table Id=myTable border="0" width="90%" cellspacing="1" cellpadding="0" bgcolor="#000000">
<tr bgcolor="#91B5F9">
<td align="middle" nowrap width="6%"><font color="#000000">删除</font></td>
<td align="center" nowrap width="44%"><font color="#000000">流程过程</font></td>
<td align="center" nowrap width="44%"><font color="#000000">部门信息</font></td>
<td align="center" nowrap width="6%"><font size="2" color="#000000">插入</font></td>
</tr>
<tr bgcolor="gainsboro" Id=Row00>
<td align="center" nowrap width="6%"> </td>
<td align="center" nowrap width="44%">拟稿
</td>
<td align="center" nowrap width="44%">......
<td nowrap width="6%" align="center">
</td>
</tr>
<input type="hidden" Id="SSMStepName" Name="SSMStepName" Value="拟稿">
<input type="hidden" Id="CCNUserInfo" Name="CCNUserInfo" Value="">
<tr bgcolor="gainsboro">
<td colspan="2" nowrap width="50%"><font Color=Blue Style="Cursor:Default">请进行流程设置</font>
</td>
<td colspan="2" align="right" nowrap width="50%"><font class="FontHtc" Onclick="Vbscript:Form.Action='SystemPage.Asp?WCI=CustomInfo&WCE=List':Form.Submit">返回>></font>
<input type="button" value="增加" Id=AddItem name="AddItem " Style="Cursor:Hand;Color:Blue">
<input type="button" value="确认" Id=SSButton Onclick="SButton()" name="SSButton" Style="Cursor:Hand;Color:Blue">
</td>
</tr>
<input type=hidden Id=BackId Name=BackId Value="">
<input type=hidden Id=BackCode Name=BackCode Value="">
<input type=hidden Id=BackKill Name=BackKill Value="False">
</table>
<script Language=Vbscript>
RowNum=0
RowCount=0
</Script>
</center>
</div>
</form></body>
</html>这是我的一个控制页面表格的东东,你可以参考,否则你可以查找“表格”,找我以前详细的介绍表格控制的贴子,有两个贴子——不是我发表的,是我解决了问题,由别人发表的~~具体地址我忘记了,呵呵~~
<col width="25" align="center"><col width="*">
<tr height=25 menuFlag="member" onmouseover="this.className='bgLight'" onmouseout="this.className=''">
<td class=iconTd><img border="0" src="img/htmlicon.gif" width="16" height="20" id="img11111" lsid="11111"></td>
<td>11111</td>
</tr>
</table>
<input type="button" value="insertRow" onclick="addrow()"><script>
function addrow(){
alert(group0.innerHTML)
group0.outerHTML=group0.outerHTML.replace(/<\/table>/i,group0.rows[group0.rows.length - 1].outerHTML + '</table>')
alert(document.all('group0').innerHTML)
}
</script>
try {
var Elm = event.srcElement;
while(Elm && Elm.tagName != "TR") {
Elm = Elm.parentElement;
}
if(Elm.parentElement.rows.length <= 3) {
alert("无法删除!");
return;
}
Elm.parentElement.deleteRow(Elm.rowIndex-1);
} catch(e) {
alert("Err 5001:\r\n" + e);
}}
function addCol(id) {
try {
var oTable = document.getElementById(id);
if(oTable.tagName != "TABLE")
alert("Err 5002");
var oList = oTable.children;
var oTBODY;
for(var i=0;i<oList.length;i++) {
if(oList[i].tagName == "TBODY") {
oTBODY = oList[i];
break;
}
}
var oTR = oTBODY.lastChild;
var newTR = oTR.cloneNode(true);
addId(newTR);
oTBODY.insertAdjacentElement("beforeEnd",newTR);
} catch(e) {
alert("Err 5002:\r\n" + e.message);
}
}
function addId(node) {
try {
if(!node.hasChildNodes()) {
//--------------处理id为line的hidden变量将其value值加一
if (node.getAttribute("type")=="hidden")
{
var temp_value=parseInt(node.getAttribute("value"))+1;
node.setAttribute("value",temp_value);
//alert(node.name+"--"+node.value);
return;
}
var prefix = node.getAttribute("id").split("_")[0];
var postfix = node.getAttribute("id").split("_")[1];
postfix = parseInt(postfix) + 1;
node.setAttribute("id",prefix + "_" + postfix);
node.setAttribute("name",prefix+"_"+postfix);
//alert(node.name);
//-------------处理增加的checkbox的value值默认为0其它增加的元素value值为空
if (node.getAttribute("type")=="checkbox")
node.setAttribute("value",1);
else
node.setAttribute("value","");
return;
}
} catch(e) {}
try {
var oList = node.childNodes;
for(var i=0;i<oList.length;i++) {
addId(oList[i]);
}
} catch(e) {
alert("Err 5003:\r\n" + e);
}
}<table width='100%' border='1' bordercolordark='#FFFFFF' cellspacing='0' cellpadding='1' bordercolorlight='#000000' id="jczb_table">
<thead>
<tr bgcolor='#EFEDEF'>
<td width="31%" align="center">数据源列名</td>
<td width="22%" align="center">是否抽取</td>
<td width="26%" align="center">属性描述</td>
<td width="21%" align="center"><button class="button" onClick="addCol('jczb_table')">添加一行</button></td>
</tr>
</thead>
<tr align="center" class="tdbg0">
<td height="11" class="tdbg0"><input name="sjylm_0" type="text" id="sjylm_0" value="" style="width:100">
<input name="line" type="hidden" id="line4" value="0"></td>
<td class="tdbg0"><input name="sfcq_0" type="checkbox" id="sfcq_0" value="1" checked>
</td>
<td class="tdbg0"><input name="sxms_0" type="text" id="sxms_0" style="width:100" value="法人单位代码" readonly> <font color="#FF0000">*</font></td>
<td>不能删除</td>
</tr>
<tr align="center" class="tdbg0">
<td height="11" class="tdbg0"><input name="sjylm_1" type="text" id="sjylm_1" value="" style="width:100">
<input name="line" type="hidden" id="line" value="1"></td>
<td class="tdbg0"><input name="sfcq_1" type="checkbox" id="sfcq_1" value="1" checked></td>
<td class="tdbg0"><input name="sxms_1" type="text" id="sxms_1" style="width:100" value="指标描述" readonly> <font color="#FF0000">
*</font></td>
<td>不能删除</td>
</tr>
<tr align="center" class="tdbg0">
<td height="23" class="tdbg0"><input name="line" type="hidden" id="line" value="2">
<input name="sjylm_2" type="text" id="sjylm_2" style="width:100"></td>
<td class="tdbg0"><input name="sfcq_2" type="checkbox" id="sfcq_2" value="1" checked >
</td>
<td class="tdbg0"><input name="sxms_2" id="sxms_2" style="width:100" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" >
</td>
<td><button class="button" onClick="delCol()">删除</button></td>
</tr>
</table>
虽然cloneNode是条可行的方式,但仿佛有些不够直接。我发现问题所在了,问题在于
objTable.insertAdjacentElement("beforeEnd", objRow);
默认的table中,隐含着tbody对象,所以该insertAdjacentElement方式的所有对象应该
是tbody,而不是table.
我是这样得到隐含的tbody对象的
objTbody = objTable.lastChild;(插入的行总在表格最后)
再
objTbody.insertAdjacentElement("beforeEnd", objRow);
便可以正常插入了不过要多谢各位让我再次研究了这个问题