Advertisement
Civilization Fanatics' Center  

Welcome to Civilization Fanatics' Center.

You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support.

Go Back   Civilization Fanatics' Forums > COLOSSEUM > Computer Talk

Notices

Reply
 
Thread Tools
Old Feb 11, 2004, 09:42 AM   #1
Xerol
Emperor
 
Xerol's Avatar
 
Join Date: Oct 2002
Location: In an IDE.
Posts: 1,542
Having some JavaScript issues...

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
xerol@lggaming.com\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
xerol@lggaming.com\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/m.../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?
Xerol is offline   Reply With Quote
Old Feb 12, 2004, 04:19 AM   #2
funxus
Orange Cycloptic Blob
 
funxus's Avatar
 
Join Date: Apr 2002
Location: Where you wish to be!
Posts: 3,390
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 is offline   Reply With Quote
Old Feb 12, 2004, 06:00 AM   #3
kcwong
Emperor
 
Join Date: Jan 2002
Location: Hong Kong
Posts: 1,108
Images: 1
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?
kcwong is offline   Reply With Quote
Old Feb 12, 2004, 06:39 AM   #4
funxus
Orange Cycloptic Blob
 
funxus's Avatar
 
Join Date: Apr 2002
Location: Where you wish to be!
Posts: 3,390
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?
funxus is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > COLOSSEUM > Computer Talk > Having some JavaScript issues...

Thread Tools

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript help Cilpot Computer Talk 8 Jul 06, 2005 01:38 AM
HELP! more javascript problems! the100thballoon Computer Talk 2 Apr 27, 2005 10:29 AM
HTML/JavaScript help. MarineCorps Computer Talk 33 Oct 04, 2004 12:11 PM
javascript stormbind Site Feedback 4 Mar 13, 2004 03:05 PM
JavaScript question Hurricane Computer Talk 2 Sep 25, 2003 06:26 AM


Advertisement

All times are GMT -6. The time now is 12:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
This site is copyright © Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR