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/

Share:
14,643

Related videos on Youtube

sabari
Author by

sabari

Web Arch

Updated on September 15, 2022

Comments

  • sabari
    sabari over 1 year

    javascript based tag ( type ='file' ) created

    and add one attribute in that tag

    that attribute name onchange, i will assign alert

    But alert is not come when choice the new file in internet explore.

    choicefile.setAttribute("onChange", "alert('test')");
    
  • Elias Van Ootegem
    Elias Van Ootegem over 11 years
    do 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