![]() ![]() Although the Internet is not under a particular organization’s control, the W3C or World Wide Web Consortium develops standards for web development. Using this function also illustrates the relationships between elements in the W3C HTML Document Object Model (DOM). These punctuation marks are necessary and separate the object from the method and action to be taken. Notice also, the periods located within the statement. The innerHTML=”new content” portion of the statement directs the browser to replace the inner HTML area or the space between the HTML element tags with the content represented by new contentbetween the quotation marks. The elementId enclosed in parenthesis refers to the ID of the element to be modified. ![]() In the code-line shown, document is the current or parent document that contains the getElementById() function. The following line from a code snippet illustrates the general form or syntax for using the getElementById() included JavaScript function:ĭocument.getElementById(elementId).innerHTML="new content" Now that we have identified the form in our HTML document, we can now refer to that form in a script. For instance, to include the id attribute to identify a form as the contactForm, we would include the id attribute in the tag as follows: You include the idattribute within an HTML tag. In JavaScript, the getElementById() function provides the capability to replace data in an element previously included in a document and identified by an id attribute. Did I mention that JavaScript is case sensitive? Well it is so when you use previously defined functions, make sure you get the upper-case and lower-case letters correct or you will receive syntax errors when the JavaScript interpreter fails to locate the function. Although that method in fact displayed the data, sometimes displaying the data on the same page from which it was retrieved enhances the appeal of the site.Īccomplishing this simple feat requires using another technique which employs the getElementByID() built-in JavaScript function. The retrieve HTML form data hub displayed the retrieved data on a new page. ![]() There are many reasons that a web designer may choose to take advantage of this ability but providing interactive pages is a likely goal. One very useful ability provided by JavaScript is the ability to replace the content of elements in an existing HTML document that was previously displayed, even empty elements. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |