<form><input type="file" name="first" onchange="jsFunction(2);">
<input type="file" name="second" onchange="jsFunction(3);"</form>
Possible to pass just numbers to the js function?
Thanks
<form><input type="file" name="first" onchange="jsFunction(2);">
<input type="file" name="second" onchange="jsFunction(3);"</form>
Possible to pass just numbers to the js function?
Thanks
That is definitely plausible, however, the onChange
event is only fired when the input has changed AND it loses focus.
Sure, you can do this. What you are really doing here is creating a function on the fly. Your jsFuction
executes when the page loads, not when the value changes. So, its return value should be a function--the function that you want to execute when the value changes. For example:
function jsFunction(number) {
return function () {
var currentValue = this.value;
alert('I was given ' + number + ' and the current value is ' + currentValue);
};
}