views:

194

answers:

3

Hello,

Are there any JavaScript events in type=file input? I.E. I would like to add an extra file input upon selecting file in one of allready created:

Diagram:] :

file input 1
file input 2
file input 3

user selects some file in input 1 and JS adds new file input

file input 1 - somefile.txt
file input 2
file input 3
*NEW* file input 4 

I'm looking for meaningful event, on which i can bind addFileInput method.

I also use jQuery 1.4 :]

Thank you

+1  A: 

i think you mean type=file ?

only meaningful way is use both onclick and onchanged and keep track of the contents to see if it's changed.

douwe
+1  A: 

here is the event logged by firebug when selecting a file with firebug:

  • click clientX=885, clientY=207
  • blur
  • focus
  • change
  • DOMActivate
  • DOMActivate
  • mouseout clientX=162, clientY=27

I guess change, is the one you are looking for.

$ ('#your_form_id input[type=file]').live ('change', function () {
  $(this).parent ().append ($('<input type="file" />'));
})

you just have to adapt the selector and the previous code should work

mathroc
thank you, i did it already with help of ionut :]
Adam Kiss
+1  A: 

I believe onchange should work.

Ionuț G. Stan