Computing.Net > Forums > Web Development > Text from txt into HTML

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Text from txt into HTML

Reply to Message Icon

Name: Dark_Kartug
Date: May 30, 2005 at 02:11:49 Pacific
OS: WinXP Pro + SP2
CPU/Ram: 2,2Ghz Pm 915/1GB DDR2
Comment:

Hi everyone. I have the following problem:

I'd like to include a basic little news section on my site for which i'd like to read out a text file and have that text displayed on my html page. The reason why i want to use textfiles is because the news bar is on almost every page and i dont want to go about having to change it on every page once the news change.

Now I know this is possible with SSI in SHTML but I have a feeling my host doesnt support that. I know way too little of ASP or PHP to do it in that as well.

Now the question is...is it possible via a javascript or even HTML code to load text from a .txt into the HTML page?

Thx up front
Dark Kartug

War sucks but the sound is good and WE are the DJ's



Sponsored Link
Ads by Google

Response Number 1
Name: jam14online
Date: May 30, 2005 at 09:31:14 Pacific
Reply:

Including a file in every page is a very simple piece of code. Here it is using the three most popular methods.

SSI/ASP

PHP

<?php include("filename.ext"); ?>

Personally, I prefer PHP because it is an altogether more straightforward language — in my opinion, anyway.

All you would need to do then is have a file, e.g. "news.inc", and modify and include one of the commands above appropriately. Then, when you edit news.inc, it will be immediately reflected on all pages.

Free PC Help forums
MiniApache


0

Response Number 2
Name: jam14online
Date: May 30, 2005 at 09:32:40 Pacific
Reply:

Damn, the SSI/PHP code got filtered out (funny, it was showing fine on the preview). Look at the end of the second paragraph on this page.

Free PC Help forums
MiniApache


0

Response Number 3
Name: Michael J (by mjdamato)
Date: May 30, 2005 at 12:40:15 Pacific
Reply:

If your host does not support PHP, ASP or one of the other scripting languages, you can use the poor man's method by using JavaScript.

There are two elements to this. First on any page where you want the text to show put this code:

<script language="javascript" src="thesourcefile.js"></script>

Note: the name of the file can be anything you want and you will need to include the path to that file in the src name as well.

Second, create the file (with notepag or another text editor). The file could go like this:

-------------Begin Script-------------
news = "Hello, todays news is as follow...";

document.write(news);
-------------End Script-------------

Of course you could use some variables and such to include the current date/time, etc.


0

Response Number 4
Name: Dark_Kartug
Date: May 31, 2005 at 17:49:22 Pacific
Reply:

ok sweet thanks to the both of you. I'll start with the Javascript first because I dont have time right now to check if PHP and ASP will work...But Im sure that it wont be a problem to get solved later on :).

Thanks so much
Cheers
Dark_Kartug


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Text from txt into HTML

Daily/Weekly updates from txt or Db www.computing.net/answers/webdevel/dailyweekly-updates-from-txt-or-db/1085.html

PDF into HTML www.computing.net/answers/webdevel/pdf-into-html/3607.html

cant access webpage outside lan ..? www.computing.net/answers/webdevel/cant-access-webpage-outside-lan-/3045.html