Solved

builduing a nav-tree for LOTS of html files

Posted on 2004-08-27
4
168 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
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…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

831 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