Javascript multiple file uploader error in Asp.Net MVC : cancel button doesn't work

testinghost

New Member
i have error in CANCEL button in file uploader.The CANCEL button does't work if i tried to remove(cancel) ADD MORE FILE button.here is the javascript code:\[code\]<script type="text/javascript"> function addFileUploadBox() { if (!document.getElementById || !document.createElement) return false; /*********************Gets the previous upload area *******************************/ var uploadArea = document.getElementById("file_region"); if (!uploadArea) return; var newLine = document.createElement("br"); uploadArea.appendChild(newLine); /********** Creating the input type of file***************************/ var newUploadBox = document.createElement("input"); // Set up the new input for file uploads newUploadBox.type = "file"; newUploadBox.size = "20"; // The new box needs a name and an ID if (!addFileUploadBox.lastAssignedId) addFileUploadBox.lastAssignedId = 100; newUploadBox.setAttribute("id", "dynamic" + addFileUploadBox.lastAssignedId); newUploadBox.setAttribute("name", "dynamic:" + addFileUploadBox.lastAssignedId); var cancelBtn = document.createElement("input"); cancelBtn.setAttribute("type", "button"); cancelBtn.setAttribute("name", "btnCancel"); cancelBtn.setAttribute("value", "Cancel"); cancelBtn.setAttribute("id", "cancel" + addFileUploadBox.lastAssignedId); // cancelBtn.setAttribute("onclick", alert(addFileUploadBox.lastAssignedId)); uploadArea.appendChild(newUploadBox); uploadArea.appendChild(cancelBtn); addFileUploadBox.lastAssignedId++; /*************Creating the input type of button***************************/ }\[/code\]here is the View page file upload code:\[code\] <p id="file_region"> <input type="file" id="file" name="file" /> <input type="button" id="cancel" value="http://stackoverflow.com/questions/3342677/Cancel" /> <input type="button" id="more_file" value="http://stackoverflow.com/questions/3342677/Attach more files" onclick="addFileUploadBox();" /> \[/code\]////////////////////////////////////////////////////////////////////
 
Back
Top