Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want my webpage to update itself by pulling info from a file

Status
Not open for further replies.

MirandaStewart

IS-IT--Management
Oct 28, 2002
2
US
I am working on a website that displays the pictures of the employees for the company I work for. I am using HTML tables to do this. I have it set up so that the main page lists each department and you can click on the department name to open up another page to view the employees for that department. Currently, I am manually updating the code as employees are moving from one department to another or as we have new hires or terminations. Is there any way I can set this webpage up so that it pulls all the information from one place (like a file or table) and basically have it update itself so that there isn't much contact with the HTML code? A few of my peers don't know HTML and I want to fix this webpage so that they can update it without having to learn HTML.
 
There are a number of ways this can be accomplished. My tool of choice is ASP or ASP.NET. Both require you to be running a MS IIS server and know some VB.

If it's a lite traffic site, you could get by with using Access as the Database, but I would reccommend something like SQL Server or MSDE
 
You will need some kind of server-side processing PHP, ASP, PERL/CGI, SHTML, ColdFusion etc. Depends what server your on Regards
David Byng
bd_logo.gif

davidbyng@hotmail.com
 
There is a possible solution without going the server route. I'm trying to find the best possible solution for this also, but here is a possibility that I have found.

Use an <iframe>. This will let you put a &quot;box&quot; on your page that will pull an outside file in to it. With any luck, you chould be able to apply a class to it so the text would come in formatted the way you want it to be.

If you are adding a picture, that just may need another iframe loading a specific picture that is just replaced every month.

Good Luck
 
Another option to consider that will allow you to get away with purely client-side coding is storing these filenames in a delimited text file and then using a tfilereader object to read them back out again.
Code:
mydata.txt file:
@personname@|@department@
@Bob@|@Science@
@Joe@|@Art@
@Jane@|@Disciplinary@

myhtml.htm file:
<html>
<head>
<script language=&quot;JavaScript&quot;>
<!--
function change(filt){
  filereader.FilterColumn = 'department';
  filereader.FilterValue = filt;
  filereader.FilterCriterion = '=';
  filereader.Reset();
}

/* This function will check for a department name in the URL */
function checkQueryString(){
  var querystring = location.search;
  querystring = querystring.substring(1); //get rid of the question mark
  var pairs = querystring.split(&quot;&&quot;);
  for(var i = 0;i < pairs.length;i++){
     var eq = pairs[i].indexOf(&quot;=&quot;);
	 if(eq != -1){
	    var argname = new String(pairs[i].substring(0,eq));
		if(argname == &quot;department&quot;){
		   /* We have a department! :) Lets change the filter */
           change(pairs[i].substring(eq+1));
		}
	 }
  }
}
//-->
</script>

<object id=&quot;filereader&quot;
        classid=&quot;clsid:333C7BC4-460F-11D0-BC04-0080C7055A83&quot;>
   <param name=&quot;DataURL&quot; value=&quot;mydata.txt&quot;> 
   <param name=&quot;UseHeader&quot; value=&quot;True&quot;>
   <param name=&quot;TextQualifier&quot; value=&quot;@&quot;>
   <param name=&quot;FieldDelim&quot; value=&quot;|&quot;>
</object>
</head>
<body onLoad=&quot;checkQueryString();&quot;>
<input type=&quot;button&quot; onClick=&quot;change('Disciplinary');&quot; value=&quot;Disciplinary&quot;>
<input type=&quot;button&quot; onClick=&quot;change('Science');&quot; value=&quot;Science&quot;>
<input type=&quot;button&quot; onClick=&quot;change('Art');&quot; value=&quot;Art&quot;>
<table datasrc=&quot;#filereader&quot;>
<thead>
   <th>Department</th>
   <th>Employee</th>
</thead>
<tr>
   <td><span datafld=&quot;department&quot;></span></td>
   <td><span datafld=&quot;personname&quot;></span></td>
</tr>
</table>

</body>
</html>

Basically we have five differant pieces of functionality here.
1)The filereader object reads the contents of the files and uses the delimiters we provide(the pipe and at) to build an internal table of the data.
2)The table is defined to have it's source from the filereader, so it automatically fills it's contents (the spans) according to their own definitions (in this case the field names personname and department)
3)The javascript function change() is called with a value to filter the depertment column by, so only rows that have the given value will be displayed
4)The javascript function called checkQueryString() checks the URL to see if there is a department request, ie:
if there is then it automatically filters the table, if there isn't than it does nothing and the entire contents of the data file wil be displayed in the table.

This is a little complicated, but basically all you have to do to update the information is go into the data file and change it. Another option along the same vein is to create an xml file that can be treated the same way (more or less).

btw, the code above is mostly on the fly, but it should work, let me know if it doesn't.
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
This space has nothing in it, it's all ni your imagination
 
Thanks for your help!! I will let you all know what route I take and how it works. Thanks!!

Miranda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top