<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Code </title>
<body>
JS implementation of multiple upload attachment file field code
<style type= "Text/css Tutorial" >. file {font:10pt; color:black;} </style>
<script language= "Web Effects" >
function AddFile () {
var filediv = document.all[' Filediv '];
var strhtml = ' <span><input type= ' file "> <button onclick=" RemoveFile (parentnode); " > Delete </button><br></span> ';
filediv.innerhtml + = strhtml;
}
function RemoveFile (obj) {
Obj.removenode (TRUE);
}
</script>
<form enctype= "Multipart/form-data" >
<div id= "Filediv" ></div>
<a href= "Javascript:void (AddFile ());" class= "File" > Add attachments </a>
</form>
Method two like Hotmail mailbox add attachment mode dynamic increase upload attachment code
<div id= "Files" >
<div>
<input Type=button onclick= "Add ();" Value=attacthment>
<script>
var html= "<input name=title type=file> <input type=button value=delete onclick=" Remove (This) ">";
function Add ()
{
var o=document.all["files"];
var div=document.createelement ("div");
div.innerhtml=html;
O.appendchild (DIV);
Div.childnodes[0].click ();
}
function Remove (obj)
{
Obj.parentelement.parentelement.removechild (obj.parentelement);
}
</script>
Method Three
<style type= "Text/css" > file {font:10pt; color:black;} </style>
<script language= "JavaScript" >
var i=0;
function AddFile () {
i++;
Currrow=conditiontable.insertrow ();
Cellc=currrow.insertcell ();
cellccontext= ' <input type= "file" Name= "file+" +i> <button onclick= "RemoveFile ();" > Removal </button><br> ';
Cellc.innerhtml=cellccontext;
}
function Findtd (o) {
if (o.nodename== "TR" | | o.nodename== "table") return;
if (o.nodename== "TD")
Return (o);
Else
return (o.parentelement);
}
function RemoveFile () {
o = Findtd (event.srcelement);
alert (o.parentelement.rowindex*1);
Conditiontable.deleterow (o.parentelement.rowindex*1);
}
function UploadFile () {
}
</script>
<form enctype= "Multipart/form-data" >
<a href= "Javascript:void (AddFile ());" class= "file" > Add attachment </a> <a href= "Javascript:void (UploadFile ());" class= "file" > Upload attachment </a>
<div id= "Filediv" style= ' Height:150px;top:150px;left:0px;overflow-x:auto;overflow-y:auto; Border-width:1pt;border-color:black; ' >
<table id=conditiontable border=1 >
</table>
</div>
</form>
</body>