I\'m trying to call a function by name .onchange of a select but nothing happens. When the function is describled after the attribute, it works.
THI
It is because the handler testMessage is not defined when binding it to the change event.
It should work if it was in the same script context like below,
Code inside are executed one by one progressive from top and testMessage function doesn't exist inside the first .
You have couple of options here,
Put it inside an anonymous function which will let your script to resolve the testMessage function later. [As suggested in Optimus Prime answer]
Include the script that has testMessage function above the script that binds the testMessage like below,