This article uses dynamic deletion of HTML elements (consult experts)
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en" >
< Html >
< Head >
< Title > Webform2 </ Title >
< Meta Name = "Generator" Content = "Microsoft Visual Studio. net7.1" >
< Meta Name = "Code_language" Content = "C #" >
< Meta Name = "Vs_defaultclientscript" Content = "JavaScript" >
< Meta Name = "Vs_targetschema" Content = "Http://schemas.microsoft.com/intellisense/ie5" >
< Script Language = "JavaScript" >
VaR Count = 0 ;
VaR Maxfile = 5 ; // Maximum allowed quantity
// Add Element
Function Addupload () {
If (Count > = Maxfile) Return ; // Restrict up to maxfile file boxes
Count ++ ;
// Each time the HTML object with different auto-increment IDS is appended to the end of the container
VaR Newdiv = " <Div id = divupload " + Count + " > "
+ " <Input id = File " + Count + " Type = file size = 50 name = upload> "
+ " <A href = javascript: delupload ('divupload " + Count + " ');> Delete </a> "
+ " </Div> " ;
Document. getelementbyid ( " Uploadcontent " ). Insertadjacenthtml ( " Beforeend " , Newdiv );
}
// Deletes a specified element.
Function Delupload (DIVA) {
Count--;
Document. getelementbyid (DIVA). parentnode. removechild (document. getelementbyid (DIVA ));
}
</ Script >
</ Head >
< Body Ms_positioning = "Gridlayout" >
< Form ID = "Form1" Method = "Post" Runat = "Server" Enctype = "Multipart/form-Data" >
< Div >
< Table >
< Tr >
< TD ID = "Tdrrmove" Width = "2000" >
<! -- Undertake the HTML container of the entire file box -->
< Div ID = "Uploadcontent" >
<! -- Default file box
<Div id = div1> <input id = file1 type = file size = 50 name = upload> </div> -->
</ Div >
</ TD >
</ Tr >
</ Table >
</ Div >
< A Href = "Javascript: addupload ()" > Add attachment </ A >
< BR />
< BR />
</ Form >
</ Body >
</ Html >