Results 1 to 4 of 4

Thread: Add txt to web page from txt file on load

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Posts
    56

    Add txt to web page from txt file on load

    I have made a nice website but require a few numbers to be taken from a txt file when the website is loaded and placed in certain paragraphs and tables on the page.
    What is the easiest way to do this. Any examples would be handy too.

    Cheers in advance
    Nick

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    SSI (server side includes) would be easiest if you can load the entire text file into one place.
    Code:
    <!-- #include file="file.txt" -->
    Else you are going to have to use a CGI related technology (Perl, PHP, ASP, JSP, etc) to parse the text file for the data you want and generate the web page.

    Either way, your web server needs to support it.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2000
    Posts
    56
    CGI is the only option. Any tips on how I would do this?

    The other thing i've been told about is document.write. Can this perform the task?

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Originally posted by skuzzle
    CGI is the only option. Any tips on how I would do this?

    The other thing i've been told about is document.write. Can this perform the task?
    document.write is client-side javascript - you most likely need a CGI script to generate that anyway, unless your text file is already javascript code.

    Doing it with CGI shouldn't be too hard. What languages do you have avaliable? Perl would be like:
    Code:
    open(INPUT, "file.txt");
    #loop and parse thru the file to find the data
    # store it in variable $data
    close(INPUT);
    
    #write the html
    print "<td>Data is $data</d>";
    #...
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width