1. Writing a JSP
1 <%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"%>2 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en">3 <HTML>4 <Head>5 <title>My JSP ' upload2.jsp ' starting page</title>6 <Scripttype= "Text/javascript" src= "js/test.js "></Script>7 </Head>8 <Body>9 <Table>Ten <TR> One <TD>Upload User:</TD> A <TD><inputtype= "text"name= "username"></TD> - </TR> - <TR> the <TD>Upload file:</TD> - <TD><inputtype= "button"value= "Add upload file"onclick= "Addinput ()"></TD> - </TR> - <TR> + <TD></TD> - <TD> + <DivID= "File"> A at </Div> - </TD> - </TR> - </Table> - </Body> - </HTML>
2. Writing JavaScript
Test.js
1 functionAddinput () {2 vardiv = document.getElementById ("File");3 4 varinput = document.createelement ("Input");5Input.type= "File";6Input.name= "FileName";7 8 vardel = document.createelement ("Input");9Del.type= "button";TenDel.value= "Delete"; OneDel.onclick =functiond () { A This. ParentNode.parentNode.removeChild ( This. parentnode); - } - the - varInnerdiv = document.createelement ("div"); - - + innerdiv.appendchild (input); - Innerdiv.appendchild (del); + A Div.appendchild (innerdiv); at}
3. Effect Demo
Using the JS implementation to dynamically add files on the page to transfer the entry