Skip to Content
Head Rush Ajax
book

Head Rush Ajax

by Brett McLaughlin
March 2006
Beginner to intermediate
448 pages
13h 33m
English
O'Reilly Media, Inc.
Content preview from Head Rush Ajax
82
Chapter 2
Use the DOM to get the phone number
You can use the Document Object Model, or DOM, from your
JavaScript to get the phone number that the customer entered into
the Break Neck order form. We’ll spend a lot more time looking at
the Document Object Model in Chapter 4. For now, just think of
the DOM as the way you ask the web browser to get information
from, or send information to, a web page.
Man, Break Neck pizza rocks. There’s
nothing like a breakfast of cold pizza, a
whipped latte from Starbuzz, and the
Webville Times to read.
<script>
var request...
function foo()
{
...
}
</script>
JavaScript
<script>
var request...
function foo()
{
...
}
</script>
Customer’s Phone Number
Customer’s Address
Customer’s Order
<script>
var request...
function foo()
{
...
}
</script>
JavaScript
Web Browser
Internet Explorer
Firefox
Opera
Safari
Mozilla
Your JavaScript uses the DOM
to ask the web browser for
information in a web page.
The browser can access a web
page, including its elds, values,
and even display properties.
document
getElementById(“phone”)
value
Use the document variable to
ask the browser for access to
the entire web page.
This tells the browser to look
for any element in the document
that has an id attribute with a
value of “phone”.
Once you’ve found an <input>
element, you can get the text
in the eld with the “value”
attribute of the eld.
the document object model
This is the actual JavaScript
code you’d ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally

Publisher Resources

ISBN: 0596102259Errata PageSupplemental Content