The dataFld , dataFormatAs , and dataSrc PropertiesYou use the dataFld , dataFormatAs , and dataSrc properties with Data Source Objects (DSOs) in the Internet Explorer, which enable you to display data from a database in tabular and field-by-field format. These properties were introduced in Internet Explorer 4.0, as you see in Table 5.17. Table 5.17. The dataFld , dataFormatAs , and dataSrc Properties
The dataSrc property holds the source of the data, such as an HTML document. This HTML document can be divided into labeled data fields with <SPAN> elements; the dataFld property enables you to refer to specific data fields in that document. The dataFormatAs holds the data format, "text" (the default), "html" , or "localized-text" (which takes into account locale-specific data). These properties apply to these elements: <APPLET> , <BUTTON> , <DIV> , <FRAME> , <IFRAME> , <IMG> , <INPUT> , <LABEL> , <MARQUEE> , <SELECT> , <SPAN> , <TABLE> , and <TEXTAREA> . Here's an example that displays data from an HTML document: (Listing 05-09.html on the web site)<HTML> <HEAD> <TITLE> Using the dataFld, dataFormatAs, and dataSrc Properties </TITLE> </HEAD> <BODY> <CENTER> <H1> Using the dataFld, dataFormatAs, and dataSrc Properties </H1> <OBJECT ID="dsoEmployees" DATA="05-10.html" HEIGHT=0 WIDTH=0> </OBJECT> Name: <INPUT TYPE="TEXT" DATASRC="#dsoEmployees" DATAFLD="NAME" SIZE=10> <P> ID: <INPUT TYPE="TEXT" DATASRC="#dsoEmployees" DATAFLD="ID" SIZE=5> <P> Hire date: <SPAN DATASRC="#dsoEmployees" DATAFLD="HIRE_DATE"></SPAN> <P> Title: <SPAN DATASRC="#dsoEmployees" DATAFLD="TITLE"> </SPAN> <P> Department: <SELECT DATASRC="#dsoEmployees" DATAFLD="DEPARTMENT" SIZE=1> <OPTION VALUE="Shipping">Shipping <OPTION VALUE="Programming">Programming <OPTION VALUE="Editing">Editing <OPTION VALUE="Writing">Writing </SELECT> <P> <BUTTON ONCLICK= "dsoEmployees.recordset.MoveFirst()" ><<</BUTTON> <BUTTON ONCLICK="if (!dsoEmployees.recordset.BOF) dsoEmployees.recordset.MovePrevious()" ><</BUTTON> <BUTTON ONCLICK="if (!dsoEmployees.recordset.EOF) dsoEmployees.recordset.MoveNext()" >></BUTTON> <BUTTON ONCLICK= "dsoEmployees.recordset.MoveLast()">>></BUTTON> </CENTER> </BODY> </HTML> Here's the data HTML document that needs to be in the same directory for this code to read in: (Listing 05-10.html on the web site)<HTML> <HEAD> <TITLE>Data Page</TITLE> </HEAD> <BODY> <H1>This page holds data.</H1> Name: <SPAN ID="NAME">Frank</SPAN><BR> ID: <SPAN ID="ID">2345</SPAN><BR> Hire Date: <SPAN ID="HIRE_DATE">12-31-2003</SPAN><BR> Department: <SPAN ID="DEPARTMENT">Shipping</SPAN><BR> Title: <SPAN ID="TITLE">Packer</SPAN><BR> Name: <SPAN ID="NAME">Mike</SPAN><BR> ID: <SPAN ID="ID">2346</SPAN><BR> Hire Date: <SPAN ID="HIRE_DATE">12-31-2003</SPAN><BR> Department: <SPAN ID="DEPARTMENT">Programming</SPAN><BR> Title: <SPAN ID="TITLE">Programmer</SPAN><BR> Name: <SPAN ID="NAME">Sammy</SPAN><BR> ID: <SPAN ID="ID">2346</SPAN><BR> Hire Date: <SPAN ID="HIRE_DATE">12-31-2003</SPAN><BR> Department: <SPAN ID="DEPARTMENT">Shipping</SPAN><BR> Title: <SPAN ID="TITLE">Packer</SPAN><BR> Name: <SPAN ID="NAME">Tamsen</SPAN><BR> ID: <SPAN ID="ID">2347</SPAN><BR> Hire Date: <SPAN ID="HIRE_DATE">12-31-2003</SPAN><BR> Department: <SPAN ID="DEPARTMENT">Shipping</SPAN><BR> Title: <SPAN ID="TITLE">Packer</SPAN><BR> Name: <SPAN ID="NAME">Kim</SPAN><BR> ID: <SPAN ID="ID">2348</SPAN><BR> Hire Date: <SPAN ID="HIRE_DATE">12-31-2003</SPAN><BR> Department: <SPAN ID="DEPARTMENT">Shipping</SPAN><BR> Title: <SPAN ID="TITLE">Packer</SPAN><BR> </BODY> </HTML> You can see the results in Figure 5.7here, the data from several records is displayed record by record. The user can move from record to record using the arrow navigation buttons at the bottom of the page. Figure 5.7. Using the dataFld , dataFormatAs , and dataSrc properties.
We'll see more on using these properties in Chapter 17. |