I'm creating some logic for dom scripting and end up finding the problem where I needed to execute multiple methods when pressing a key. It seems the last onkeyup
defined is the one which executes, here's some code:
First method:
...var elements=$$('[id^='+table+']&[id$='+tableField+']');
elements.each(function filter(item) {
//for each item
item.onkeyup = function() { ...
Second method:
...//for each referenced input
for(var i=0, fields=htmlFieldElems.length;i<fields;i++){
//set keyup event for involved fiels in the expression
$(htmlFieldElems[i]).onkeyup = function() {...
It might happen that the input element might be the same in both methods and both need to execute when something changes... so what's the best way to deal with this?