请问各路高人:
如何动态在当前页的表格中追加行啊?(不提交 表格id=product)
在线等待!马上结帐!
谢谢了!
<%if rs.next()!=fasle%>
<tr>
<td>
<%=rs.getString()%>
</td>
</tr>
用Dhtml
通过改动innerHTML属性动态增加行数
var e = document.all.product;
var tr = e.insertRow(); //增加一行;
tr.insertCell(); //行里增加一列
tr.insertCell();
tr.insertCell();
同意meizz
借用一下fason的收藏
http://fason.nease.net/zhuanti/table/sort.htm
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>现场照片</title>
<script language="javascript">
function CheckData()
{
nLimFileSize=parseInt(document.all.FILE_SIZE.value);
nLimWidth=parseInt(document.all.PICTURE_WIDTH.value);
nLimHeight=parseInt(document.all.PICTURE_HEIGHT.value);
for(i=0;i<document.getElementsByName("Name").length;i++)
{
oName=document.getElementsByName("Name")[i];
oFile=document.getElementsByName("FilePath")[i];
nFileSize=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].fileSize;
nWidth=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].width;
nHeight=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].height;
if(oName.value=="")
{
oName.focus();
alert("名称不能为空!");
return false;
}
if(nFileSize==-1)
{
oFile.focus();
alert("图片为空或类型无效!");
return false;
}
if(nFileSize>nLimFileSize)
{
oFile.focus();
alert("图片文件太大,请限制在" + nLimFileSize + "字节以内!");
return false;
}
if(nWidth>nLimWidth||nHeight>nLimHeight)
{
oFile.focus();
alert("图片太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!");
return false;
}
}
}
function AddMoreRow()
{
oRow=event.srcElement.parentNode.parentNode;
oTable=event.srcElement.parentNode.parentNode.parentNode.parentNode;
oNewRow=oTable.insertRow();
for(i=0;i<oRow.cells.length;i++)
{
oNewRow.insertCell().innerHTML=oRow.cells[i].innerHTML;
}
oRow.all("DelBtn").disabled=false;
oNewRow.all("DelBtn").disabled=false;
oNewRow.className="content";
frames["_hideFrame"]._AddMoreRow();
}
function DeleteThisRow()
{
oRow=event.srcElement.parentNode.parentNode;
oTable=event.srcElement.parentNode.parentNode.parentNode.parentNode;
if(oTable.rows.length>1)
{
frames["_hideFrame"]._DeleteThisRow(oRow.rowIndex);
oTable.deleteRow(oRow.rowIndex);
if(oTable.rows.length==1)
{
oTable.all("DelBtn").disabled=true;
}
}
}
function DisabledKeyInput()
{
if(event.keyCode!=8&&event.keyCode!=46) event.returnValue=false;
}
function HidePreviewPicture()
{
document.all.img.innerHTML="";
}
function VerifyPicture()
{
nLimFileSize=parseInt(document.all.FILE_SIZE.value);
nLimWidth=parseInt(document.all.PICTURE_WIDTH.value);
nLimHeight=parseInt(document.all.PICTURE_HEIGHT.value);
oRow=event.srcElement.parentNode.parentNode;
oImg=frames["_hideFrame"].document.all.VerifyTable.rows[oRow.rowIndex].all.tags("img")[0];
oImg.src=event.srcElement.value;
document.all.img.innerHTML="<img src=" + event.srcElement.value + ">"
document.all.img.childNodes[0].attachEvent("onerror",HidePreviewPicture)
if(oImg.readyState=="complete")
{
if(oImg.fileSize==-1)
{
alert("文件类型无效!")
}
else if(oImg.fileSize>nLimFileSize)
{
alert("图片文件太大,请限制在" + nLimFileSize + "字节以内!")
}
else if(oImg.width>nLimWidth||oImg.height>nLimHeight)
{
alert("图片太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!")
}
}
}
</script>
</HEAD>
<body class=scrollbar1 topmargin=10>
<xml style="display:none" id=PictureSet>
<ROOT><PICTURE_WIDTH>800</PICTURE_WIDTH><PICTURE_HEIGHT>600</PICTURE_HEIGHT><FILE_SIZE>819200</FILE_SIZE></ROOT>
</xml>
<input datasrc="#PictureSet" datafld="PICTURE_WIDTH" id="PICTURE_WIDTH" style="display:none">
<input datasrc="#PictureSet" datafld="PICTURE_HEIGHT" id="PICTURE_HEIGHT" style="display:none">
<input datasrc="#PictureSet" datafld="FILE_SIZE" id="FILE_SIZE" style="display:none">
<form target="_hideFrame" method=post enctype="multipart/form-data" action="BatchAddPicture_DB.asp?kch=<%=kch%>&caseno=<%=caseno%>&lx=<%=lx%>" onsubmit="return CheckData()">
<table><th><%=lx%>批量上传</th></table>
<table>
<tr class=content>
<td nowrap>名称*</td>
<td><input type="text" name="Name" size=15 maxlength="50"></td>
<td nowrap>文件路径*</td>
<td>
<input type=file name="FilePath" size=15 onkeydown="DisabledKeyInput()" onpropertychange="VerifyPicture()">
</td>
<td nowrap>说明</td><td><input type=text name=Description size=45><input type="button" class="input1" value="增加" onclick="AddMoreRow()"></td>
<td nowrap>
<input type="button" class="input1" id=DelBtn value="删除" disabled onclick="DeleteThisRow()">
</td>
</tr>
</table>
<table>
<tr align =center>
<td class="tijiao" align =center>
<input type="submit" class="input1" value="保存"> <input type="reset" class="input1" value="取消">
</td>
</tr>
</table>
<iframe src="about:blank" width=100% height=0 name="_hideFrame"></iframe>
<div id="img"></div>
<div id=tempHTML style="display:none">
<script>
function _AddMoreRow()
{
oCell=document.all.VerifyTable.insertRow().insertCell();
oImg=document.createElement("img");
oImg.attachEvent("onreadystatechange",_VerifyPicture);
oImg.attachEvent("onerror",_PictureError);
oCell.appendChild(oImg);
}
function _DeleteThisRow(rowIndex)
{
document.all.VerifyTable.deleteRow(rowIndex);
}
function _PictureError()
{
if(event.srcElement.fileSize==-1)
{
alert("无效的图片类型!");
}
}
function _VerifyPicture()
{
oImg=event.srcElement;
if(oImg.readyState=="complete")
{
nWidth=parseInt(parent.document.all.PICTURE_WIDTH.value);
nHeight=parseInt(parent.document.all.PICTURE_HEIGHT.value);
nFileSize=parseInt(parent.document.all.FILE_SIZE.value);
if(oImg.width>nWidth||oImg.height>nHeight)
{
alert("图片尺寸太大,请限制在" + nWidth + "X" + nHeight + "大小!")
}
else if(oImg.fileSize>nFileSize)
{
alert("图片文件超出限定大小,请限定在" + nHeight + "字节以内!")
}
}
}
</script>
<table border=0 id=VerifyTable>
<tr><td><img border=0 onerror="_PictureError()" onreadystatechange="_VerifyPicture()"></td></tr>
</table>
</div>
<script language=javascript>
function InitFrame()
{
frames["_hideFrame"].document.write(document.all.tempHTML.innerHTML);
}
window.onload=InitFrame;
</script>
</form>
</BODY>
</HTML>