This is my function and it should change the onClick attribute of the HTML input, but if I use
document.getElementById(\'buttonLED\'+id).onclick = \"writeLED
Another solution is to set the 'onclick' attribute to a function that returns your writeLED function.
document.getElementById('buttonLED'+id).onclick = function(){ return writeLED(1,1)};
This can also be useful for other cases when you create an element in JavaScript while it has not yet been drawn in the browser.