You might wonder what to do with the DOM properties. There are numerous applications possible, for example, creating pages that allow the user to dynamically toggle between languages or presentations. This small example demonstrates this idea in a simple form.
<<form action="#" method="get">> Say Hello in: <<select onchange="document.getElementById('thephrase').firstChild.data = this.options[this.selectedIndex].value;">> <<option value="Hello">>English<</option>> <<option value="Bonjour">>French<</option>> <<option value="Hola">>Spanish<</option>> <</select>> <</form>> <<div id="thephrase">>Hello<</div>>
We could have used the innerHTML property commonly supported in most 6.x browsers, but we opted for the full DOM approach here.
Of course, we could have made the whole page rewrite itself for the language selected, but the idea should be clear enough.
You could also apply a similar idea to selecting a style sheet for the page, as demonstrated here.
There are also many possibilities with dynamic tables. Consider sorting cells when a user clicks on a column header. You might even provide a spreadsheet-like interface where the user can click on a cell and modify it. Given that every aspect of the page is changeable, it is really up to you to figure out what to do with the DOM. The next few chapters will present some common uses of both traditional and modern Document objects including form validation, page effects such as mouseovers, and navigation systems.