How do I use a text doc in an html website?

Hi

I’m trying to set up a webpage with a list of events.
I was thinking of having the html webpage getting the
list of information from a text document.

So I can simply retype my text document, upload it at any time,
then the html page will refresh using the new text document
and show a new list of events each time I upload a new text
document.

I hope this makes sense.
Any help would be greatly received.

Macaruba

I’m not much of a programmer but this is the source code from the Dreamweaver doc I’ve been working with:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Macaruba - List Test</title>
<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.style1 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	font-size: 18px;
}
.style2 {color: #990000}
-->
</style>
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body bgcolor="#FF0000" onLoad="MM_preloadImages('../images/home2.png')">
<table width="75%" align="center">
  <tr>
    <td><div align="center"><a href="../index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','../images/home2.png',1)"><img src="../images/home1.png" alt="home" name="Image1" width="36" height="38" border="0"></a></div></td>
  </tr>
  <tr>
    <td height="500" align="center"> <p>&nbsp;</p>      <p>      
    <script type="text/javascript">
/***********************************************
* IFRAME Scroller script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//specify path to your external page:
var iframesrc="list.txt"
//You may change most attributes of iframe tag below, such as width and height:
document.write('<iframe id="datamain" src="'+iframesrc+'" width="450px" height="400px" marginwidth="10" marginheight="10" hspace="0" vspace="0" frameborder="3" scrolling="yes"></iframe>')
      </script>
  &nbsp;</p></td>
  </tr>
</table>
</body>
</html>

It does work but I want to be able to specify the font and colour and size of the text brought in, any other ideas?

If the content is required within the page I would be tempted to use the require directive rather than include, it would result in an error occurring if the file (for example) is unavailable or missing but it would most likely be better than having a page load (skewed due to the information being missing) with errors spanning all over the page - in the example Stephen mentioned with PHP you would simply replace “include” with “require” to tell the server that the page should only load if the required information is available (if not it’ll produce an error so you should be more aware that there’s a problem). :slight_smile:

Thanks for that, but if my text file that I want appear within the html
is called “list.txt” what do I put between the <pre></pre> tags?

Thanks I’ll give it a try.

If it is plain text then just load it inside <pre></pre> tags in the page.

That depends on what server side language you have available.

If you are using server side includes you’d use

<pre><!--#include virtual="list.txt" --></pre>

If you are using PHP it would be

<pre><?php include 'list.txt' ?></pre>