possible to pass variable to javascript function from html form like this?
<form><input type="file" name="first" onchange="jsFunction(2);">
<开发者_JS百科input type="file" name="second" onchange="jsFunction(3);"</form>
Possible to pass just numbers to the js function?
Thanks
Yes, it is possible :)
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);
};
}
精彩评论