- function addAttachment()
- ...{
- var strAttachPathArray;
- var strFileName="";
- var strAttachPath=""; //the path of the file...
- var attach = "";
- var attachDIV = this.document.getElementById("attachmentList"); //this div will save the attachment
- for(var i=0;i<document.forms[0].elements.length;i++) //loop the whole form
- ...{
- if(document.forms[0].elements[i].type=="file") //find if it is a <input type="file" elements
- ...{
- if(document.forms[0].elements[i].value != "") //this is not a empty path.
- ...{
- strAttachPath = document.forms[0].elements[i].value; //get this path
- strPathArray = strAttachPath.split("//");//separate this string as a array depends on "/". / needs convert.
- strFileName = strPathArray[strPathArray.length-1]; //get the file name,if you can not understand please debug and search by your self
- attach = attach + "<img src='images/attachment.GIF' border='0' />" + strFileName + " ";
- //img is a pic....
- }
- }
- }
- attachDIV.innerHTML = attach;
- }