多附件、带有预览功能的HTML页面
2008-01-05 18:43:37 来源:WEB开发网<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>
更多精彩
赞助商链接