Programming | Advanced table 10-5 HTML elements that support data binding
HTML element
Binding properties
Can more
New data
Can the table
Lattice bindings
Can as
HTML display
A
Href
Not
Not
Not
Applet
PARAM
OK
Not
Not
BUTTON
InnerText and innerHTML
Not
Not
OK
Div
InnerText and innerHTML
Not
Not
OK
FRAME
Src
Not
Not
Not
Iframe
Src
Not
Not
Not
Img
Src
Not
Not
Not
INPUT
Checked
OK
Not
Not
TYPE=CHECKOBX INPUT
Value
OK
Not
Not
Type=hidden INPUT
Vale
OK
Not
Not
Type=label INPUT
Value
OK
Not
Not
Type=password INPUT
Checked
OK
Not
Not
Type=radio INPUT
Value
OK
Not
Not
Type=text LABEL
InnerText and innerHTML
Not
Not
OK
LEGEND
InnerText and innerHTML
Not
Not
Not
MARQUEE
InnerText and innerHTML
Not
Not
OK
OBJECT
Param
OK
Not
Not
SELECT
Selected <OPTION> element text
OK
Not
Not
SPAN
InnerText and innerHTML
Not
Not
OK
TABLE
No
Not
OK
Not
TEXTAREA
Value
OK
Not
Not
2. Single record binding
A single record binding is used to display only a single row of data. For example, consider the following code:
ID: <span datasrc= "#dsoData" datafld= "au_id" ></SPAN><BR>
Name: <span datasrc= "#dsoData" datafld= "au_fname" ></SPAN><BR>
Last Name: <span datasrc= "#dsoData" datafld= "au_lname" ></SPAN><BR>
Phone: <span datasrc= "#dsoData" datafld= "Phone" ></SPAN><BR>
Address £ <span datasrc= "#dsoData" datafld= "Address" ></SPAN><BR>
City: <span datasrc=, "#dsoData" datafld= "City" ></SPAN><BR>
State: <span datasrc= "#dsoData" datafld= "state" ></SPAN><BR>
Zip: <span datasrc= "#dsoData" datafld= "Zip" ></SPAN><BR>
Contact: <span datasrc= "#dsoData" datafld= "contract" ></SPAN><BR>
With a single record binding, each bound HTML element determines the data source (DATASRC) and the bound field (DATAFLD).
The results of the above data binding are shown in Figure 10-5:
Figure 10-5 Results of a single record binding
As a result, this already satisfies the requirements, but because the space is ignored in the HTML document, the data is not arranged neatly. Data binding makes it easy to get data, but it doesn't look very nice. A good way to do this is to use a table to align the data.
<table id= "Tbldata" >
<TR><TD>ID:</TD>
<td><span datasrc= "#dsoData" datafld= "au_id" ></SPAN></TD></TR>
<tr><td>first name:</td>
<td><span datasrc= "#dsoData" datafld= "au_fname" ></SPAN></TD></TR>
<tr><td>last name:</td>
<td><span datasrc= "#dsoData" datafld= "au_lname" ></SPAN></TD></TR>
<TR><TD>Phone:</TD>
<td><span datasrc= "#dsoData" datafld= "Phone" ></SPAN></TD></TR>
<TR><TD>Address:</TD>
<td><span datasrc= "#dsoData" datafld= "Address" ></SPAN></TD></TR>
<TR><TD>City:</TD>
<td><span datasrc= "#dsoData" datafld= "City"
[1] [2] [3] [4] Next page