When Stackoverflow Sends You in the Wrong Direction (processing file input)

https://stackoverflow.com/questions/2805977/how-do-i-call-a-javascript-function-after-selecting-a-file-from-the-select-file

I have a file input element

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

How do I call a JavaScript function after selecting a file from the dialog window and closing it?

Yikes! No answer marked right and the most upvoted says :

jQuery("input#fileid").change(function () {

    alert(jQuery(this).val())
});

I say : OMG

All you need to do is 

<input type="file" onchange="calledFunction()">

FYI, to use the Duke Javascript Library, in your HTML (say in Codepen) :

<script src="http://www.dukelearntoprogram.com/course1/common/js/image/SimpleImage.js">

</script>

What they didn't do a terrific job of covering in the course (or their documentation) : whether SimpleImage objects can be passed to/from functions? Ans : Yes, just do var name_of_var = function_that_returns_SimpleImage(args); // Yes, args can include SimpleImage objects..

Comments

Popular posts from this blog

How Should You Put Your Text in a Box?

Tricks : Getting Image URL When Page Doesn't Want You To!

A Web Interface to Try Dual Key Caesar Cipher Encryption and Decryption