Question:

How do I import text from an external .txt or excel file (or other) into a webpage using simple code (html)?

by  |  earlier

0 LIKES UnLike

My client wants a quote on each webpage. I thought it would be great if he could update them himself.

 Tags:

   Report

2 ANSWERS


  1. You have the following options:

    Use some server side include command using PHP, ASP, or SHTML.

    This takes a file that is in the confines of the web directory or known location directly on the web server and places whatever is in the file directly where the include command is.

    Use javascript to write some predefined text, using the document.write() command.

    Set up a database that can store the information and then displayed whereever required. But this will take PHP or ASP or PERL and is far more complicated than the first option.

    You cannot use simple HTML to do something dynamic on a website.

    At the very least, your client will need access to a FTP Client to upload a new file whenever a change in quote is desired.

    Here's the simplest route to go:

    In a text editor write this:

    var theQuote = 'Four score and seven years ago...';

    Save the file as quote.js

    Upload the file to the root directory of the website.

    On each page that the quote will be displayed:

    In the HEAD:

    <script type="text/javascript" src="quote.js"></script>

    In the BODY where you want the script to show:

    <script type="text/javascript">

    document.write(theQuote);

    </script>

    That's it. All that needs to happen is to edit the quote.js file to make changes.


  2. dont think you need to just name them .htm when you save as then ftp to server. if this isnt the answer your looking for e-mail me and give me details.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.