>> DAVID J. MALAN: Let's implement a web page that says hello to a user, along
the way demonstrating the DOM, the document object model, or the tree
structure that really is underneath the hood when you render a web page.
>> Let's take a look.
Here, in dom-0.html, notice that inside of the pages' body, I have a
form tag, the unique identifier for which is, quote unquote, "demo."
Meanwhile, I also have an onsubmit attribute, otherwise known as an event
handler, onsubmit, which specifies that when this form is submitted, a
function that's apparently called greet should be executed.
And then false should be returned.
>> Why false?
Well, I don't actually want to submit this form to a remote Web server in
the traditional way.
I want to circumvent that form submission and do something with it
client-side using JavaScript.
Indeed, notice here.
At the head of my web page, I have a script tag, inside of which is the
beginnings of that function called greet.
>> What do I actually want to do?
Well, inside of greet, let's simply call the alert function.
And then print out something like hello, with a space.
And then concatenate onto the end of that the result of calling
document.getElementByID, specifying specifically the unique identifier,
quote unquote, "name."
>> And specifically, once we've gotten that element, the node in the tree
that represents this web page, let's specifically get it's value by
specifying .value.
And then, just for fun, let's concatenate on to the end of that an
exclamation point.
>> Let's now save this file, open it in a browser, and see a hello.
http://localhost/dom-0.html.
>> There's that form.
Let's go ahead and type in my name.
Followed by clicking Submit.
And there we see hello, David!
That's me.