<SCRIPT language=javascript>
var modified = 0;
var currentLine = -1;
var line = -1;
var allCount = 4;
function addUploadFile()
{
newRow = tableA.insertRow(tableA.rows.length);
newRow.id = "fileUploadID";
newRow.ln = allCount;
newRow.pn = allCount;
c1 = newRow.insertCell(0);
c1.ln=allCount;
c1.pn=allCount;
c1.innerHTML = "<input type = file size=40 name='filename"+allCount+"' ln="+allCount+" pn="+allCount+">";
c2=newRow.insertCell(1);
c2.ln=allCount;
c2.pn=allCount;
c2.onclick=delIt;
c2.align = 'center';
c2.innerHTML="删 除";
c3=newRow.insertCell(2);
c3.ln=allCount;
c3.pn=allCount;
c3.onclick=showPic;
c3.align = 'center';
c3.innerHTML="预 览";
allCount++;
}
function delIt()
{
line=parseInt(event.srcElement.ln,10)
if (line>0)
for (i=1; i<tableA.rows.length ; i++)
{
if (fileUploadID[i].ln==line )
{
var temp=eval("document.uploadform.filename"+line+".value");
if ( temp.length>0 )
{
if (!confirm("确认删除此附件?")) { return; }
}
tableA.deleteRow(i);
}
}
}
function showPic()
{
line=parseInt(event.srcElement.ln,10)
if (line>0)
for (i=1; i<tableA.rows.length ; i++)
if (fileUploadID[i].pn==line)
{
var temp=eval("document.uploadform.filename"+line+".value");
if ( temp.length>0 )
{
c4=fileUploadID[i].insertCell();
c4.align = 'center';
c4.innerHTML="<img src='"+temp+"' width='50px' /> ";
fileUploadID[i].pn = '';
}
}
}
</SCRIPT>
<FORM name=uploadform method="post" enctype="multipart/form-data">
<TABLE align=center border='1' id='tableA' width='800PX' name='tableA'>
<TR id=fileUploadID>
<TD width="40%" align=center> 附件列表 </TD>
<TD width="20%" align=center> </TD>
<TD width="20%" align=center> </TD>
<TD width="20%" align=center> </TD>
</TR>
</TABLE>
<TABLE align=center border=1 rules=all width="800PX" nowrap>
<TR>
<TD align=center>
<input type="button" onclick="addUploadFile();" value="添 加">
</TD>
</TR>
</TABLE>
</FORM>
本文地址:http://com.8s8s.com/it/it13725.htm