I am trying to make a javascript function work on submitting the form, the function doesnt seem to run. Can anyone help?
When attaching the event handler to the form element, the scope of the event handler is the form and not the window
As input elements inside a form are attached as properties to the form object, where the name is the key, calling upload()
in the event handler, where the scope is the form, would equal calling form.upload()
, but the form already has an element with that name so form.upload
is the upload button, not the upload()
function in the global scope.
To solve it, either rename the function or the element
FIDDLE