I'm using jquery.js 1.2.6 and the following snippet of javascript to
implement a multiple file upload (there is also a plugin available on
the jquery site, but it provides all possible bells and whistles in
many lines of code; this seemed a much more lightweight approach).

However, while it works nicely in Firefox and Safari, with IE7 it goes
into a loop: specifically, it keeps repeating the inserted <div> with
the name of the selected file and the 'Remove' button.  The code is:

/* Upload.js
*  allows user to upload indefinite number of files
*  requires nquery.js
*/
$(document).ready(function(){
  $('#fileinput').after('<div id="files_list" style="padding:
5px;background:#fff;font-size:x-small;"><strong>Selected files:</
strong></div>');
  $("input.upload").change(function(){
     doIt(this);
   });
});
function doIt(obj) {
  $(obj).hide();
  $(obj).parent().prepend('<input type="file" class="upload"
name="file[]" />').find("input").change(function() {doIt(this)});
  var v = obj.value;
  if(v != '') {
    $("div#files_list").append('<div>'+v+'&nbsp;&nbsp;<input
type="button" class="remove" value="remove" title="remove this file
from those to be uploaded"/></div>').find("input").click(function(){
       $(this).parent().remove();
      $(obj).remove();
      return true;
      });
  }
};

Can anyone see what might be wrong?  It is presumably a quirk of IE7
that is causing the problem, since it works on other browsers.

Thanks for any advice, either about a solution or how to pin point the
problem.

Nigel

Reply via email to