Browse DevX
Sign up for e-mail newsletters from DevX


Manipulate Data in Internet Explorer with the Tabular Data Control  : Page 3

The Tabular Data Control is an ActiveX control built into Internet Explorer (versions 4 and upwards). You can use this control to extract ordered contents from an ASCII file into HTML elements, and then display them—with a little help from JavaScript.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Add a Little JavaScript
In the first example, the element displayed the first entry of the data file. When you add another entry to the file, the data file (data1.txt) looks like this:

name|age ~Premshree Pillai~|~19~ ~Vinod~|~18~

You can use JavaScript to see the second entry (i.e. Vinod 18). The following code shows how:

<OBJECT ID="data2" CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83"> <PARAM NAME="DataURL" VALUE="data2.txt"> <PARAM NAME="UseHeader" VALUE="TRUE"> <PARAM NAME="TextQualifier" VALUE="~"> <PARAM NAME="FieldDelim" VALUE="|"> </OBJECT> <SCRIPT LANGUAGE="JavaScript"> /* Get the complete data record set */ var dataSet=data1.recordset; /* Go to next data */ dataSet.moveNext(); </SCRIPT> <SPAN DATASRC="#data1" DATAFLD="name"></SPAN> <SPAN DATASRC="#data1" DATAFLD="age"></SPAN>

The output will be:

Vinod 18

Initially, the entire data is stored in a variable dataset using the recordset method. The moveNext() method points to the next data item (next row). Other methods that can be used are:
  • moveFirst(): Points to the first data item (first row).
  • moveLast(): Points to the last data item (last row).
  • EOF: Checks to see if you have reached the end of the file.
It might be beneficial to see this control in a more dynamic example. Listing 3 is of a JavaScript Ticker that ticks a number of messages. Each message points to a particular URL. The ticker reads its messages and the corresponding URL from a text file (tickerData.txt).

Though this functionality is only availble in MSIE, it is extemely versatile—especially when you've got small amounts of character-delimited data that you want to extract and display using client-side scripting.

Premshree Pillai studies engineering in Information Technology at Mumbai University, Mumbai, India. He is a programming enthusiast and maintains a Website, where he posts his scripts. He is also a freelance writer and has written for a range of popular Indian magazines.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date