Object Hierarchy
Object hierarchy relates to how you call a certain object. It works like this. biggest.nextbiggest.3rdbiggest.etc. Here is an example. It relates to where I live.
earth.usa.ny.mytown.mystreet.myhouse
If you are going to use object hierarchy (and trust me, you will), you need to name all of you elements, that way the JavaScript can find that. For example, if you name a form "form" the JavaScript interpreter knows to go to that form if "window.form" is typed. Be sure to name all elements of a form. Say you wanted to get the value of an element called select inside the form named "form," you would type:
window.form.select.value
Now, if you are writing a letter to me, you don't have to say Earth in my address. It is assumed that you are talking about Earth. So it is optional. It is the same thing with JavaScript, you don't need to put window before the rest of the hierarchy. So you could just type:
form.select.value
Here is a real example of using object hierarchy.
if (document.form.email.value=" "){
//if it it blank
alert('Please enter an email address')
//pop up a message
The next section is Methods
Back Homepage Basic JavaScript Next