views:

38

answers:

3
<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

+1  A: 

Yes, it is possible :)

silent
A: 

That is definitely plausible, however, the onChange event is only fired when the input has changed AND it loses focus.

Topher Fangio
A: 

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);
  };
}
pkaeding