Browse DevX
Sign up for e-mail newsletters from DevX


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

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

Extract and Display Data
The first example is fairly simple. My name and age are stored in the text file "data1.txt." Listing 1 shows how to display my name and age using the tag.

The output will display:

Premshree 19

In Listing 1, note the attributes within the SPAN tags. DATASRC specifies the data source to use—the same as the ID of the object initialized, in this case, "data1." The DATAFLD attribute specifies which field is to be displayed. Since the "data1.txt" file has two fields ("name" and "age"), specifying the DATAFLD as "name" will display the name.

You can use this same method to extract data from a text file into any HTML element. However, there is a flaw. If your data file contains more than one entry, you wont be able to extract all the values directly.

In these cases, use the TABLE tag.

The next example will illustrate how you can use the TABLE tag to solve this problem.

Display in a Tabular Form
Listing 2 demonstrates how to extract this data and display it on the Web page in a tabular form. The text file in this example stores the name, age, and sex of three people:

name|age|sex ~Premshree Pillai~|~19~|~male~ ~Vinod~|~18~|~male~ ~Usha~|~19~|~female~

The code in Listing 2 contains three data fields (DATAFLD) in three different tags (columns) only once. The Web page automatically displays all three sets of values (three rows). You can add as much content as you want to the text file without making any modifications to the HTML code that extracts these values.

The output looks like this:

Name : Age : Sex :
Premshree Pillai19male

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