Multi-Attachment Upload component Demo _javascript tips

Source: Internet
Author: User
1. You can dynamically add or delete objects that upload files
2. Automatically process file path to get file name.
3. Automatically calculate the number of files to be uploaded
<pead> <meta http-equiv= "content-language" content= "ZH-CN" > <script> function mcreatefile (obj) { var eF var mname mfilename.innerhtml= "" if (obj.id== "File") {for (i=0;i<mfile.children.length-1;i++) {if (mfile.children[i].value== "") {Mfile.removechild (mfile.children[i])} else {mname=mfile.children[i].value.split ("\") mfilename.innerhtml+= "<div id=namedetail title= '" + mname[mname.length-1]+ "' >" +mname[mname.length-1]+ "</div>"} mstatus.innerhtml= "Total <b>" + (mfile.children.length-1) + "</b> files waiting to upload"} if (obj.id== "File_new") {ef=document.createelement (' <inpu T type= "file" name= "file" size= "Id=file_new onpropertychange=" Mcreatefile (This) ">") mfile.appendchild (EF) obj . id= "File"}} </script> <style> table{FILTER:progid:DXImageTransform.Microsoft.Shadow (directio N=135,color= #999999, StreNGTH=3); input{border:1px Soild #000000; Font-family:verdana,arial, song body; font-size:12px; padding:2px; } #mTD {line-height:24px; } #mFile {width:203px; Float:left; | #mFileName {float:right; width:182px; } #NameDetail {Overflow:hidden; width:176px; Color: #000000; Font-family:verdana,arial, song body; font-size:12px; Cursor:default; height:22px; } #mstatus {font-size:12px; Color: #ff0000; } </style> </pead> <body> <form name=frm method=post> <div align= "center" > <table B Order= "1" width= "420" bordercolor= "#0066cc" cellpadding= "4" bgcolor= "#D0F0FF" > <tr> <td bgcolor = "#3399FF" height= "align=" "Center" ><font color= "#FFFFFF" size= "3" ><b> Add attachment </b></font> </td> </tr> <tr> <td id=mtd> <div id=mfile><input type= "file" n Ame= "File" size= "Id=file_new onpropertychange=" Mcreatefile (this) ></div> <div ID=mfilename></div> <div id=mstatus> A total of <b>0</b> files waiting for upload </div> </td> </tr> </table> </div> </form> </body>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.