This article has made some modifications on the basis of the previous article. Added an onclick event to tr. Run the following code for the specific effect.
HTML code:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
<SCRIPT>...
Function bindtotable (field)
...{
Xmlcd. recordset. absoluteposition = field. rowindex;
Td_title.innertext = xmlcd. recordset ("title ");
Td_artist.innertext = xmlcd. recordset ("artist ");
Td_year.innertext = xmlcd. recordset ("year ");
}
</SCRIPT>
</Head>
<Body>
<XML id = "xmlcd" src = "cd_catalog.xml" async = "false"> </XML>
<Table>
<Tr> <TH> title: </Th> <TD id = "td_title"> </TD> </tr>
<Tr> <TH> ARTIST: </Th> <TD id = "td_artist"> </TD> </tr>
<Tr> <TH> year: </Th> <TD id = "td_year"> </TD> </tr>
</Table>
<Br/>
<Table datasrc = "# xmlcd" border = "1">
<Thead>
<TH> title </Th>
<TH> artist </Th>
<TH> year </Th>
</Thead>
<Tr onclick = "bindtotable (this)">
<TD> <span dataworks = "title"> </span> </TD>
<TD> <span dataworks = "artist"> </span> </TD>
<TD> <span dataworks = "year"> </span> </TD>
</Tr>
</Table>
</Body>
</Html>
The XML file used is the XML file used at that time.