views:

47

answers:

2

How to call a JavaScript function after the selection of file from the Open Dialog window close event. in HTML using HTML file type="file".

I have a file input element

<input type="file" id="fileid" >

How can i call a JavaScript function after the file open dialog window close event.

A: 

Try this:

document.getElementById('fileid').onchange = function(){
  // your code here
};

Basically, this should fire when you have chosen a file (after selecting and closing the window).

Sarfraz
Its not working ;(
coderex
A: 

jQuery("input#fileid").change(function () {
    alert(jQuery(this).val())
});
mike clagg
okey i will try
coderex
nope its not working after the selection of a file
coderex
Sorry there was a typohttp://geektasking.com/clients/stackoverflow/2805977/
mike clagg
It should work. Do you run this script during `$(document).ready()`?
BalusC
@coderex - How are you testing this? Opening and closing this won't work since you didn't **change** anything, you have to actually select a file to trigger the event.
Nick Craver