473,785 Members | 2,843 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to populate HTML table from local text file.

Hi,

I am looking for a way to populate an HTML table from an external
local text file which looks like this:

DATE/TIME LAT. LON. DEPTH. ML.
-------------------- ---------- ---------- ------- -------
21/03/2005-04:06:03 XX,XX XX,XX 171 3,42
21/03/2005-12:23:53 XX,XX XX,XX 500 5,4
21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
21/03/2005-18:47:51 XX,XX XX,XX 162 3,91
21/03/2005-19:29:49 XX,XX XX,XX 500 3,51
21/03/2005-20:04:51 XX,XX X,X 75 3,72

The file could have more rows (DATA) that I show here. The file is
provided to me on a daily basis and I have to update a web page daily
with the contents of the file.

I considered using JavaScript embedded in the HTML page but I am a
newbie on what scripting for the web it refers.

How can I populate the HTML table with this text file which changes
everyday.

Also, is it possible to use php client-side only, without a server?

Your help, suggestions and feedback questions will be much
appreciated.

Thanks.

Alex.
Jul 17 '05
11 8149
alex wrote:
Mick White <mw***********@ rochester.rr.co m> wrote in message news:<b%******* *************@t wister.nyroc.rr .com>... [...]

<div id="foo"><--INCLUDE FILE HERE--></div>

Forgive my ignorance, but, how do i include the file as dictated right
above?
Is there some kind of HTML statement that allows you to include an
external text file ? Please clarify as am a newbie on this. Thanks
Mick.

Alex.

Search for "SSI".

Mick

<script type="text/JavaScript">
onload= function(){
var d=document.getE lementById("foo ").innerHTML.sp lit(/\s+/)
document.getE lementById("foo ").innerHTML=ta ble_maker(5,d);
}


[...]

Jul 17 '05 #11
alex wrote:
Hi,

I am looking for a way to populate an HTML table from an external
local text file which looks like this:

DATE/TIME LAT. LON. DEPTH. ML.
-------------------- ---------- ---------- ------- -------
21/03/2005-04:06:03 XX,XX XX,XX 171 3,42 21/03/2005-12:23:53 XX,XX XX,XX 500 5,4
21/03/2005-12:43:10 XX,XX XX,XX 553 5,38 21/03/2005-18:47:51 XX,XX XX,XX 162 3,91 21/03/2005-19:29:49 XX,XX XX,XX 500 3,51 21/03/2005-20:04:51 XX,XX X,X 75 3,72
The file could have more rows (DATA) that I show here. The file is
provided to me on a daily basis and I have to update a web page daily
with the contents of the file.

I considered using JavaScript embedded in the HTML page but I am a
newbie on what scripting for the web it refers.

How can I populate the HTML table with this text file which changes
everyday.

Also, is it possible to use php client-side only, without a server?

Your help, suggestions and feedback questions will be much
appreciated.

Thanks.

Alex.


Server-based preprocessors were designed for this sort of thing; any
time you attempt it at the client, you're in the wild-wild-west, so to
speak, hoping for a reasonably controlled environment (unlikely).
Nevertheless: you could simply download that text file into a hidden
iframe in the page and extract the data from there...browser support
for this - and DOM table-building - is pretty good these days. See if
this does anything. You may have to find any control characters
inserted by googlegroups and s & r them....sorry about that.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">

body {
font-size: 100%;
background: #9a9;
}
h3 {
width: 180px;
font: 18px "arial black";
color: #474;
margin: 80px auto 0 auto;
}
#stuff {
width: 600px;
margin: 10px auto;
}
#stuff th {
font: 11px "arial black";
color: #060;
letter-spacing: .4em;
border-left: 3px #000 solid;
border-right: 1px #000 solid;
background: #fff;
}
#stuff td {
font: normal 12px monospace;
text-align: center;
padding: 3px;
border-top: 1px #888 solid;
border-right: 1px #000 solid;
border-bottom: 1px #888 solid;
border-left: 3px #000 solid;
background: #d0d8d0;
}
#buffer {
display: none;
}

</style>
<script type="text/javascript">

onload = function()
{
if (!document.getE lementById
|| !document.getEl ementsByTagName )
return;
var frm = null,
prenode,
tbod = document.getEle mentById('tbod' ),
data = '';
if ((frm = top.frames['buffer']) //iframe
&& frm.document)
{ //get <pre> parent
prenode = frm.document.ge tElementsByTagN ame('pre').item (0);
if (null != prenode
&& null != prenode.firstCh ild
&& /#text/.test(prenode.f irstChild.nodeN ame)) //text node
{
data += prenode.firstCh ild.data; //read
data = data.split(/[\n\r]/); //separate lines
data.splice(0, 2); //lose first two (legend)
var i = 0,
l = data.length,
rowdata,
ii, ll, tr, td;
for (; i < l; ++i)
{
tr = document.create Element('tr'); //new row
tbod.appendChil d(tr);
rowdata = data[i].split(/\s{3,}/); //separate bits
for (ii = 0, ll = rowdata.length; ii < ll; ++ii)
{
td = document.create Element('td'); //new cell
td.appendChild( document.create TextNode(rowdat a[ii]));
tr.appendChild( td);
}
}
}
}
}

</script>
</head>
<body>
<h3>&amp;#149 ; Mystery Data &amp;#149;</h3>
<table id="stuff">
<thead>
<tr>
<th>DATE/TIME</th>
<th>LAT.</th>
<th>LON.</th>
<th>DEPTH.</th>
<th>ML.</th>
</tr>
</thead>
<tbody id="tbod">
</tbody>
</table>
<iframe id="buffer" name="buffer" src="data.txt"> </iframe>
</body>
</html>

Made some assumptions about the consistency of the text formatting.

Jul 17 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
24595
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML. -------------------- ---------- ---------- ------- ------- 21/03/2005-04:06:03 XX,XX XX,XX 171 3,42 21/03/2005-12:23:53 XX,XX XX,XX 500 5,4 21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
7
6232
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data in the same format as the XSD (the XML file/string was created using this same schema). The XML file/string may contain data for a single table or for several tables at once. The question is:
0
2442
by: Nithin | last post by:
My code as an txt attachment. I have 2 drop down list boxes that on selection populate text boxes from my database table. I am able to display the correct values in these text boxes. I have 2 questions: 1) I would like the user update these text fields that get populated with data from the database. For some reason I get the error when I change the textbox value.
1
6530
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp page. I am able to call values from file in my jsp page. But as dynamic values can be any in no...
0
4073
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp page.But as dynamic values can be any in no i don't know how could i populate all those in my jsp...
11
7399
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and the Dropdown doesnt have any items.. The requirement is that as soon as one goes on typing the letters in the StudentName-textbox the corresponding matching names have to appear
13
31421
by: =?Utf-8?B?S2VzdGZpZWxk?= | last post by:
Hi Our company has a .Net web service that, when called via asp.net web pages across our network works 100%! The problem is that when we try and call the web service from a remote machine, one outside of our domain, we get the error.. ** Client found response content type of 'text/html; charset=Windows-1252', but expected 'text/xml' **. We can discover the web service by typing in the url of the asmx so we know the server can 'see' it...
7
7337
by: jcnone | last post by:
Does anyone know how to populate form fields on a html web page (client side) with data from an Excel file (CSV) or text file. I am currently having to input data to many text fields manually. I would like to transfer the data into the web form programatically from a CSV/text file. How can this be done? I am new to javascript, but I will work through the challange if possible. Please help! Thanks. Jman
3
3011
by: Sunny | last post by:
Hi, Can someone tell me, How to load the Body Html from a text file that contains javascript. to Manage my files I am creating an Index Page. <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title></title>
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8974
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.