onchange with alert not working in ie
14,643
You can do two ways,
1.. Using HTML, add onchange
event inline
<input type="file" id="file_select" name="file_select" value="" onchange="alert('File selected')" />
Demo: http://jsfiddle.net/CS3xJ/1/
2.. Using JS,
choicefile.onchange = function(){
alert('File selected')
}
Demo: http://jsfiddle.net/CS3xJ/2/
Related videos on Youtube
Comments
-
sabari over 1 year
javascript based tag (
type ='file'
) createdand add one attribute in that tag
that attribute name
onchange
, i will assign alertBut alert is not come when choice the new file in internet explore.
choicefile.setAttribute("onChange", "alert('test')");
-
Elias Van Ootegem over 11 yearsdo bear in mind that
onchange
doesn't bubble in IE on select elements. To delegate an onchange event you'll need a rather lengthy workaround