Section 2.12. Use the DOM to get the phone number


2.12. 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.

     JavaScriptYour JavaScript uses the DOM to ask the web browser for information in a web page.     DocumentUse the document variable to ask the browser for access to the entire web page.In JavaScript, you just type in "document" to use this object.     Web BrowserThe browser can access a web page, including its fields, values, and even display properties.     getElementById("phone")This tells the browser to look for any element in the document that has an id attribute with a value of "phone".This is the actual JavaScript code you'd type in.     valueOnce you've found an <input> element, you can get the text in the field with the "value" attribute of the field. 




Head Rush Ajax
Head Rush Ajax (Head First)
ISBN: 0596102259
EAN: 2147483647
Year: 2004
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net