views:

36

answers:

1

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:

<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***************************/
    }

here is the View page file upload code:

          <p id="file_region">
            <input type="file" id="file" name="file" />
            <input type="button" id="cancel" value="Cancel" />   
    <input type="button" id="more_file" value="Attach more files" onclick="addFileUploadBox();" />    

////////////////////////////////////////////////////////////////////

A: 

I've used this jQuery plugin for uploading multiple files at a time and thought it's been great: http://www.fyneworks.com/jquery/multiple-file-upload/

Jeff T
wow great jquery plugin....thank 4 that...i have implemented in asp.net mvc...it work
Mik-Mark