Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

builduing a nav-tree for LOTS of html files

Posted on 2004-08-27
4
Medium Priority
?
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 25

Accepted Solution

by:
James Rodgers earned 500 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 500 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

618 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