can i call multiple onkeyup events on the same html input-tag?
<input style="float: left; width: 50px;" id="PersonLength" name="PersonLength" onkeyup="checkNr(this.id)" onkeyup="fill()" type="text">
something like that?
<input style="float: left; width: 50px;" id="PersonLength" name="PersonLength"
onkeyup="checkNr(this.id), fill()" type="text">
or like this? ive treid them both but i might have the wrong syntax? or is there a better way to do it?
Another way to Rome:
If you want to call multiple functions and set the event inline, you could write an extra method that will call all methods.
for ex.
<input style="float: left; width: 50px;" id="PersonLength" name="PersonLength" onkeyup="yourElemOnKeyup(this.id)" type="text">
Script
function yourElemOnKeyup(id){
checkNr(id);
fill();
}
You do not call onkeyup
events, they are events, they happen.
You can use the EventListener API to add multiple event listeners.
var input = document.getElementById("my_input");
input.addEventListener("keyup", function () {
doSomething();
});
input.addEventListener("keyup", function () {
doSomethingElse();
});
// .. etc
The alternative notation would be:
<input .. onkeyup="checkNr(this.id); fill()" type="text">
^- semicolon
This is similar to:
var input = document.getElementById("my_input");
input.addEventListener("keyup", function () {
checkNr(input.id);
fill();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With