This week's book giveaways are in the Refactoring and Agile forums. We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line! See this thread and this one for details.
It looks like that script should be in an onload function (or jquery or the like equivalent) rather than in the main body of the page between HTML form elements. That way it still runs after the select box is rendered, but is more logically separate.