221Chapter 15Generic HTML Element ObjectsThe value you assign (Best web hosting site)

221Chapter 15Generic HTML Element ObjectsThe value you assign to the objectelement s idattribute is the identifier that your scriptsuse to communicate with the data after the page and data completely load. You can thereforehave as many uniquely named TDCs loaded in your page as there are data source files youwant to access at once. The initial binding of the data to HTML elements usually comes when you assign values to thedatasrcand datafldattributes of the elements. The datasrcattribute points to the dsoidentifier (matching the idattribute of the objectelement, preceded with a hash symbol), while the datafldattribute points to the name of the field whose data should be extracted. When you use data binding with an interactive element such as a table, multiple records aredisplayed in consecutive rows of the table (more about this in a moment). Adjust the dataSrcand dataFldproperties if you want the same HTML element (other than atable) to change the data that it displays. These properties apply to a subset of HTML elementsthat can be associated with external data: a, applet, body, button, div, frame, iframe, img, input(most types), label, marquee, object, param, select, span, and textareaobjects. In some cases, your data source may store chunks of HTML-formatted text for renderinginside an element. Unless directed otherwise, the browser renders a data source field as plaintext even if the content contains HTML formatting tags. But if you want the HTML to beobserved during rendering, you can set the dataFormatAsproperty (or, more likely, thedataformatasattribute of the tag) to HTML. The default value is text. ExampleListing 15-8 is a simple document that has two TDC objects associated with it. The external filesare different formats of the U.S. Bill of Rights document. One file is a traditional, tab-delimiteddata file consisting of only two records. The first record is a tab-delimited sequence of fieldnames (named Article1 , Article2 , and so on); the second record is a tab-delimitedsequence of article content defined in HTML:

ARTICLE I

Congress shall make…

The second file is a raw text file consisting of the full Bill of Rights with no HTML formattingattached. When you load Listing 15-8, only the first article of the Bill of Rights appears in a blue-borderedbox. Buttons enable you to navigate to the previous and next articles in the series. Because thedata source is a traditional, tab-delimited file, the nextField()and prevField()functions cal- culate the name of the next source field and assign the new value to the dataFldproperty. Allof the data is already in the browser after the page loads, so cycling through the records is asfast as the browser can reflow the page to accommodate the new content. Listing 15-8: Binding Data to a Page