Solved

builduing a nav-tree for LOTS of html files

Posted on 2004-08-27
4
161 Views
Last Modified: 2010-04-06
I am making a HTML based products catalog.
I have lots of products where each product is stored in its own HTML file (picture + info).
each file is named like this:    name_num.html
in one of the frames in the site I have three buttons: on to go to "home" on next and one prev.
I want to make the buttons work in such way: when I am on page : name_X.html and I click name_X+1.html and for back: name_X-1.html

I know I can make it manualy, like editing the link on each page but I have more then 300 file so....

Please tell me how can I make this work.
0
Comment
Question by:knfevg
4 Comments
 
LVL 25

Accepted Solution

by:
James Rodgers earned 125 total points
ID: 11915368
why not convert the entire catalogue to database driven, then you only need one page and you can generate teh links from the info in the database. the way you are sugghesting does not allow for easily adding more catalogue items and will be very hard to maintian and update if teh site look changes.
0
 
LVL 19

Assisted Solution

by:dakyd
dakyd earned 125 total points
ID: 11916281
Jester's right, the cleanest solution is probably to use a database.  If that's not to your liking or you can't use a database, an alternative suggestion would be to use javascript to automatically create the links for you.  You'd have to fill in the min and max values for the links, and you'd have to make sure that this script is included in every one of your pages (this is why Jester's solution is cleaner - you only need to change 1 page if you want to make a change, as opposed to changing all 300+).  It'll help if you save the script into a js file, then go through all your pages once to put in <script type="text/javascript" src="WHATEVER YOU NAME THE JS FILE"></script>.  After that, just edit the js file if you want to make changes.  Anyhow, hope that helps.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<script type="text/javascript">
var baseName = "test";
var min = 0;
var max = 300;

function init()
{
  var num = unescape(document.location.href).replace(/\D/g, "");
  num = parseInt(num);
  var theDiv = document.createElement("div");
  document.body.appendChild(theDiv);
  if (num > min)
  {
    var prevA = document.createElement("a");
    prevA.id = "prevPage";
    prevA.innerHTML = "Previous Page";
    prevA.style.marginLeft = "2px";
    prevA.style.marginRight = "2px";
    prevA.href = baseName + "_" + (num - 1) + ".html";
    theDiv.appendChild(prevA);
  }
  if (num < max)
  {
    var nextA = document.createElement("a");
    nextA.id = "nextPage";
    nextA.innerHTML = "Next Page";
    nextA.style.marginLeft = "2px";
    nextA.style.marginRight = "2px";
    nextA.href = baseName + "_" + (num + 1) + ".html";
    theDiv.appendChild(nextA);
  }
}

window.onload = init;
</script>
</head>

<body>
</body>
</html>
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now