Current location: Hot Scripts Forums » General Web Coding » JavaScript » Load Text file and display in table format.

Load Text file and display in table format.

Reply
  #1 (permalink)  
Old 11-05-09, 09:32 AM
salmansohail salmansohail is offline
New Member
 
Join Date: Nov 2009
Posts: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Load Text file and display in table format.

I wish to display the output in a nice table format, the text file contains loads of rows and columns and each column separates either by space " " or "," .
Please can someone help, at the moment it says, Problem retrieving data. Unknown

Further I am not sure if i need a webserver to make this work, as currenlty all html files are stored on a network drive and everything works fine except this section.

Code:
<html>
<head>
<script type="text/javascript">
var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
    document.getElementById('T1').innerHTML=xmlhttp.responseText;
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}
</script>
</head>

<body onload="loadXMLDoc('testdetails1.txt')">
<div id="T1" style="border:1px solid black;width:300;padding:5"></div><br />
<button onclick="loadXMLDoc('testdetails2.txt')">Click</button>
<button onclick="loadXMLDoc('testdetails3.csv')">Click</button>

</body>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-16-09, 07:03 AM
maneetpuri maneetpuri is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

WebServer for sure is required to run this and after you have installed the web server and get some error then you will have to share that error with people here so that can comment about the reason for the same.

Cheers,
__________________
Maneet Puri
Web Design Company
KPO Services
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to display text file using php/html umarmir_123 HTML/XHTML/XML 7 05-19-09 08:06 AM
writing form data to a text file topside Script Requests 2 03-02-07 03:28 AM
Need Your HelP! Loading Multiple External Text into Multiple Dynamic Text Fields Flash_Boi Flash & ActionScript 2 03-30-06 04:27 PM
Storing field names of a table when storing query results in a text file ??? Newbie2005 PHP 0 10-21-05 06:53 AM


All times are GMT -5. The time now is 05:46 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.