Is it possible to use an external text file for a variable

This is a discussion on "Is it possible to use an external text file for a variable" within the JavaScript Forum section. This forum, and the thread "Is it possible to use an external text file for a variable are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 14th, 2006, 21:42
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Is it possible to use an external text file for a variable

I have a vertical scroller that displays current news but as news changes I would like to be able to update it wihtout having to edit the javascript code.

Is it possible to use a plain text file (.txt) to have the news and include that in the code?

Here is how it works at the minute

var marqueecontent='<p class="style2">Current News</p>'

but i would like to incude a file instead of hard coding it
Reply With Quote

  #2 (permalink)  
Old Sep 15th, 2006, 00:34
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Is it possible to use an external text file for a variable

PHP or ASP is better suited for the job than JavaScript. To acheive the effect in PHP, you need to change the extension from, say, .html to .php. Then create a file with the news in it on your server with the .php extension.

Open up index.php (or whatever the page you want to have the news on is called) and input the following where you want the news to appear:

PHP: Select all

<html>

    <body>
        <p>Current News</p>
<?php
include "news.php";
?>
        <p>This is the rest of the document</p>
    </body>
</html>
PHP will treat news.php like an HTML file, so you can put in formatting, images, links, etc.
Reply With Quote
  #3 (permalink)  
Old Sep 15th, 2006, 17:25
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Is it possible to use an external text file for a variable

Is the 'current news', news of your own making, so to speak, or is it coming from a third party.

If it's the latter, look at using an RSS feed and having that update into your page automatically.
Reply With Quote
Reply

Tags
possible, use, external, text, file, variable

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Load External .JS File Before Anything Else tox0tes JavaScript Forum 1 Jul 10th, 2007 14:03
Help with function to read external file jwhite68 Flash & Multimedia Forum 4 Jul 6th, 2007 15:18
How do I add new variable in a .TPL file toasty PHP Forum 1 Oct 9th, 2006 18:27
Load .swf file with External text in Another Flash document ien Flash & Multimedia Forum 3 Aug 31st, 2006 14:29
Can I invoke a timeline from an external text file Array? d-kam Flash & Multimedia Forum 5 Apr 1st, 2005 09:25


All times are GMT. The time now is 04:54.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43