Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i have two files. First file has contents (ie. entire data is in single row separated by space)
Eg:
Test1 Test2 Test3


In 2nd file, i have written below code to get data from first file.
HTML
<div id="Page1"><iframe src="../awards/Page1.html"></iframe></div>

this shows the data as in first file.

now i want to display the data in table format and each value should come in new row. There should be only one column.
ie. output should be
Test1
Test2
Test3


how do i apply javascript for loop to achieve this?

Regards,
Posted
Updated 14-Feb-14 9:41am
v2
Comments
What have you tried?
archies_gall 14-Feb-14 13:33pm    
i tried below code:

<script language="javascript">

var fso,txt;
fso=new ActiveXObject("Scripting.FileSystemObject");
txt=fso.OpenTextFile("Test1.txt",1);
function table_maker(txt){
var rows=txt.split(','), 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;
}
</script>

<body önLoad="table_maker()">
So, what is the issue here? Have you debugged.
One note here - ActiveXObject don't work with Browsers other than IE.
archies_gall 14-Feb-14 13:50pm    
Issue i dont know... i am not getting any output only.
and sorry but i dont know how to debug javascript code :(

and also,what else I can use instead of ActiveXObject so that it is supported by other browsers too?
Okay, refer my answer. :)

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900