Having some JavaScript issues...

Xerol

Emperor
Joined
Oct 6, 2002
Messages
1,542
Location
In an IDE.
I'm working on our new website(Level Ground Gaming and part of the "new" main page takes a data file on the server("newsdb.txt") and loads it in, using the info inside to render the html code for the news items. Problem is, I get squat for output, and I don't know why. Here's the code:
Code:
<SCRIPT LANGUAGE="JavaScript">

var temp;
var topposted=0;
var title, postedby, email, edate, etime, numpara;
newsDB = new File("newsdb.txt");
newsDB.open("r");

while(!newsDB.eof()) {

title = newsDB.readln();
document.write(title);
postedby = newsDB.readln();
email = newsDB.readln();
etime = newsDB.readln();
edate = newsDB.readln();
if (topposted==0){
topposted=1;
document.write('<b><font size="+2" face="courier new">News </font><i>(Last updated '+edate+' @ '+etime+')</i></b>');
}
numpara = newsDB.readln();
numpara = parseInt(numpara);
document.write('<hr color=#0080ff align=left width=25% size=4>');
document.write('<font size="+2"><b>'+title+'</b></font><br>');
document.write('<font size="-1"><i>Posted by <a href="'+email+'">'+postedby+'</a> at '+etime+' on '+edate+'</i></font>');
for(i = 0; i < numpara; i++){
temp = newsDB.readln();
document.write('<p>'+temp+'</p>');
}
newsDB.close();
}

</SCRIPT>

And the data file:
Code:
Image Problems Fixed\n
Xerol\n
[email]xerol@lggaming.com[/email]\n
09:11 AM\n
10 Feb 2004\n
1\n
In all browsers other than IE, the images were not displaying. The problem has now been fixed. \n
Level Ground Gaming Opens\n
Xerol\n
[email]xerol@lggaming.com[/email]\n
03:38 AM\n
09 Feb 2004\n
2\n
Welcome to Level Ground Gaming's website. Now officially in business, we hope to begin providing great games within the next few months. Last night, the team put together the final details and this site was born. Up until yesterday, Level Ground Gaming(formerly unformally known as Level Ground Productions) was just a few people who programmed for fun. Well, it still is, but now we're getting organised with it and are going to use our skills and ingenuity to put together a few projects. The first project we have planned, which has been in a "thought" stage up until now, is known as StarFields. We're not going to reveal much now, other than the details given on the "Current Projects" page. \n
As an introduction to the site, take a look around. It's not much now, but it's simple and has everything it needs. The Site Navigation bar at the bottom of the page will take you to wherever you need to go, as long as it's on this page. "Home" takes you to this page. Later on, in addition to News, there will be new project announcements and other content that will be constantly changing. About LGG is an overview of what Level Ground Gaming is, and when finished will contain some information about the people behind the games. About This Page describes the site content, much like this paragraph does, and includes some information that may be helpful to people interested in creating web pages. Our Current Projects page will keep you up-to-date on what we are working on now, potential release dates of demos and full versions, and once in a while, an opportunity to test our latest project. Occassionally we want to see how our products perform on a variety of machines, and this is where you come in. Feedback is important to us, and the Contact Us link at the bottom of the page will let you get directly in contact with us. \n

I tried it with and without the \n's, with still no results.
The readln(); function is detailed here:
http://developer.netscape.com/docs/manuals/js/server/jsref/
(Click on "Index" in the left panel, then find "File" and click on it)

The only problem I can see is that of the path. According to the netscape site, the path argument in the declaration is "A string representing the path and filename in the format of the server's file system (not a URL path)." newsdb.txt is in the same folder as index2.html so there shouldn't be any problem, should there?
Here's the page in just HTML(that renders fine): http://www.lggaming.com
And the non-working javascript page: http://www.lggaming.com/index2.html

Thanks in advance for any help.

EDIT: Ok, I definitely think the problem is with the path now, because someone on AIM just debugged the code and it said "File not found", so therefore I need to figure out what the server's root path is for our site. Does anyone use Yahoo Small Business hosting?
 
I'm not very good at Javascript, but I'd assume that you need the script to run at the server to be able to access/open the file, but I think scripts if nothing else is written (like RunAtServer?) are run on the client. I might be wrong though.
 
funxus, QwertySoft is not trying to read a file on the client machine (if that's possible, that'd be a disaster) - instead a file on the server.

I don't think JavaScript is the best tool for such... is there any other server-side technology provided by your host?
 
I never thought he was trying to read the file on the client. I meant, is it possible to read a file on the server from the client like that? I know you can read the file, but can you open it for reading over the internet?
 
Back
Top Bottom