0

Hi,

I got a text file ('testdetails2.txt') and my text file looks something like this:

abc123, 234 pqr,xyz "type"
bc123, 234 pqr,xyz "type"
c123, 234 pqr,xyz "type"
n23, 234 pqr,xyz "type"
aj23, 234 pqr,xyz "type"

As you notice, it has got "," aswell a blank space and "". all i wish to to do is preset the contents of the text file in a nice html table.

Please can someone help?

<html>
</head>   
<script type="text/javascript">   
function loadTxtFile(){
..
..

}
</script>

<body>   
<div id="T1" style="border:1px solid black;width:300;padding:5"></div><br />   
<button onclick="loadTxtDoc('testdetails2.txt')">Click</button>   
<button onclick="loadTxtDoc('testdetails3.csv')">Click</button>   
 </body> 
</html>
2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by SALMANSOHAIL
0

Just to test the javascript code, this is what i did, but it says error.

var txt ='abc123, 234 pqr,xyz "type"\nbc123, 234 pqr,xyz "type"\nc123, 234 

pqr,xyz "type"\nn23, 234 pqr,xyz "type"\naj23, 234 pqr,xyz "type"'
function table_maker(txt){
var rows=txt.split('\n'), r, cells, c, j, i=0;
var table='<table>';
while(r=rows[i++]){
table+='<tr>';
cells=r.split(',');
j=0;
while(c=cells[j++]){
table+=('<td>'+c+'</td>');
}
table+='</tr>';
}
table+='</table>';
return table;
document.getElementById("T1").innerHTML=table;
}

html

<div id="T1" style="border:0px solid black;width:300;padding:5"></div> 
<button onclick="table_maker();">Authorisation Checker Error log </button>
0

<html></head> <script type="text/javascript"> function loadTxtFile(){.... }</script> <body> <div id="T1" style="border:1px solid black;width:300;padding:5"></div><br /> <button onclick="loadTxtDoc('testdetails2.txt')">Click</button> <button onclick="loadTxtDoc('testdetails3.csv')">Click</button> </body> </html><html>
</head>
<script type="text/javascript">
function loadTxtFile(){
..
..

}
</script>

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

0

Sumeet, please can you explain again, i can't see any update in your post...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.