Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading data off files and populating tables

Status
Not open for further replies.

maxpower1

Programmer
Jul 29, 2001
488
0
0
US
i use client side javascript to get input lines from the data file. I need to populate the screen with this data(assuming using <table> tag). Then when a user clicks on a particular row(in <tr> or <td>, it will display a new window with the info from the row clicked(I know how to do this too:)).

My question is: What is the best way to implement the population of data onto the screen that allows me to attach the rowclick event to the data presented on the screen?

thx
 
Manpower1.

I saw your post, and perhaps you can help me.
How can I read a text file using Java Script?
My text file is 50 rows with 5 comma-delimited fields in each.

As I read each row in the file,I plan to place each row into a 50 row array, and later parse out the fields I want into variables.

Any help in reading a text file (either in the site or at a defined URL) will be appreciated.
Thanks,
Billg
 
First of all:-
1. Do you want to read it using server script or..
2. Do you want to read it using client script.

I designed mine using client side. I did this using IE 6. First of all, this is an intranet application. User don't have access to the outside world. Hence, I ENABLED the security option in IE(I think it's the third option from the top under Internet Options (Click on security tab and then the custom level button).

I did not try this in netscape but I heard security is
pretty &quot;intense&quot; in Netscape. Like I said, this is an intranet app.

Anyways,
HERE IS MY SCRIPT (It returns one line at a time). It search for a number and return the string on the right. You might want to improvise it to your liking. Let me know if I could assist you further:-

function searchDeviceDescr(iDisabledCode) {

sDisabledCode = iDisabledCode.toString() + &quot; &quot;;

var deviceFSO = new ActiveXObject (&quot;Scripting.FileSystemObject&quot;);

try {
var deviceTStream = deviceFSO.OpenTextFile (&quot;C:\\somedirectory\\text.DAT&quot;);

while (! deviceTStream.AtEndOfStream) {

//read the text
var strLineText = deviceTStream.ReadLine();

if ((strLineText.substr(0, sDisabledCode.length)) == (sDisabledCode.substr(0, sDisabledCode.length))) {

//sResult contains the substring needed
var sResult = strLineText.substr(sDisabledCode.length, strLineText.length);
deviceTStream.Close();
return sResult;
}
}
deviceTStream.Close();

}
catch (ex){
alert(&quot;File Text.dat not found: &quot; + ex);
}

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top