JavaScript Forms

I am working on development a web app game. It is being written in JavaScript. I had learned how to do forms, so I made the game use a form. The majority of the screen is a big select area. I was going crazy because my JavaScript code was generating errors. The browser kept complaining that document.forms[0].mySelect was either NULL or not an object.

This was troubling because I had coded successful projects that used this technique. Googling the web also showed many examples of this working. To get by I hacked some getElementById calls instead. It still troubled my. I was running Internet Explorer 8. This stuff should have been working.

Near the end of my game development cycle I had to add more items to the form such as a status message. That is when I found the root cause of the problem. The select element was not within the form tags in the HTML. Ouch. No wonder JavaScript could not access the select object. It was just not part of the form. Now I got an action item to go back and use the familiar technique to access the form data in JavaScript code.