dataSrc property
Sets or retrieves the identifier of the data source that is bound to the element.
In HTML, only Internet Explorer supports table creation dynamically from XML.
If you want to implement similar functionality in other browsers, you need to use JavaScript.
For further details, see the page for the XMLHttpRequest object.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: dataSrc |
Possible values:
String that sets or retrieves the identifier of the data source.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the dataSrc attribute:
|
||||
<xml id="movies"> <?xml version="1.0"?> <movies> <movie> <name><b>Clark Kent</b></name> <jobtitle>Superman</jobtitle> <born>1966</born> </movie> <movie> <name><b>Lois Lane</b></name> <jobtitle>Reporter</jobtitle> <born>1964</born> </movie> </movies> </xml> <table width="100%" cellpadding="0px" cellspacing="2px" border="1px" datasrc="#movies" datapagesize="2" > <thead> <tr> <th>Name</th> <th>Jobtitle</th> <th>Born</th> </tr> </thead> <tbody> <tr> <td><span datafld="name" dataformatas="html"></span></td> <td><span datafld="jobtitle"></span></td> <td><span datafld="born"></span></td> </tr> </tbody> </table> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the dataSrc property with XML data island:
|
||||
<head> <script type="text/javascript"> function ChangeDataSrc () { var dataTable = document.getElementById ("dataTable"); if ('dataSrc' in dataTable) { dataTable.dataSrc = (dataTable.dataSrc == "#movies2") ? "#movies1" : "#movies2"; } else { alert ("Your browser doesn't support this example!"); } } </script> </head> <body> <xml id="movies1"> <?xml version="1.0"?> <movies> <movie> <name><b>Clark Kent</b></name> <jobtitle>Superman</jobtitle> <born>1966</born> </movie> </movies> </XML> <xml id="movies2"> <?xml version="1.0"?> <movies> <movie> <name><b>Lois Lane</b></name> <jobtitle>Reporter</jobtitle> <born>1964</born> </movie> </movies> </xml> <table id="dataTable" width="100%" cellpadding="0px" cellspacing="2px" border="1px" datasrc="#movies1" datapagesize="1"> <thead> <tr> <th>Name</th> <th>Jobtitle</th> <th>Born</th> </tr> </thead> <tbody> <tr> <td><span datafld="name" dataformatas="html"></span></td> <td><span datafld="jobtitle"></span></td> <td><span datafld="born"></span></td> </tr> </tbody> </table> <button onclick="ChangeDataSrc ();">Change data source!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
a, button, div, frame, iframe, img, input:button, input:hidden, input:password, input:reset, input:submit, input:text, isindex, label, legend, marquee, span, table, textarea
Related pages:
dataFld
dataFormatAs
dataPageSize
firstPage
lastPage
nextPage
previousPage
recordNumber
oncellchange
ondataavailable
ondatasetchanged
ondatasetcomplete
dataFormatAs
dataPageSize
firstPage
lastPage
nextPage
previousPage
recordNumber
oncellchange
ondataavailable
ondatasetchanged
ondatasetcomplete
External links:
User Contributed Comments