Click to See Complete Forum and Search --> : automatically creating CSS boxes using javascript


shabam
07-29-2005, 04:36 PM
I don't do much programming, but I know my way around after poking around.

I would like to automate keeping my page up to date.

The problem is that I create a bunch of boxes via CSS like so:

<div class="sidebox">
<div id="bodyText"> <a href="/blabla/main.html"> Home
</a></div>
</div>

I have 7 of these at the begining of everypage, that point to all 7 pages of my site.

Now, if I decide to have 8 pages all the sudden, I have to manually go to each page and add the html code needed for the CSS to work.

So I need something that will say: ok, call the function to make and "X" amount of CSS boxes, each with a corresponding link on every page. I can control the "X" and what where each links points to.

Note I cannot use php.

Is this a javascript problem? is arrays they answer, or is there something much simpler?

Mongus
07-29-2005, 05:14 PM
You can do it in JavaScript but that's really not the right way. Search engines and people without JavaScript would never be able to get into your site.

If you still want to do it you can include a JavaScript file on each of your pages that would generate the menu.

Place this where you want the menu to appear:

<script type="text/javascript" src="menu.js"></script>


menu.js:

document.write('<div class="sidebox"><div id="bodyText"><a href="/blabla/main.html">Home</a></div></div>');


Then whenever you want to change the menu for all pages you just update menu.js.

Again, this is not the right way to do it. I'm just showing how you can do what you asked.

shabam
07-29-2005, 05:30 PM
what would be the correct way of doing it?

shabam
07-29-2005, 05:42 PM
One solution I could think of in theory is to have a program that would do the above, but simply create the html on the pages, then I take those and post them on the internet. (what would be the options for programs for these commands?)

Also, I'm sure there are other ways, which I would also be cool to learn...

Mongus
07-29-2005, 06:02 PM
Yes, if you don't have any way to do it server-side that would be the best way. You could use just about any programming language you wanted to generate the pages on your computer.

By far the easiest way is to use a server-side language to dynamically include another file right into your HTML.

shabam
07-29-2005, 06:16 PM
Yes, if you don't have any way to do it server-side that would be the best way. You could use just about any programming language you wanted to generate the pages on your computer.

By far the easiest way is to use a server-side language to dynamically include another file right into your HTML.


Ok cool, thanks.
Can you expand on server-side language? I'm looking for a big picture kind of explaination.

Mongus
07-29-2005, 07:19 PM
Server-side languages run inside of the web server (or along side it) to make it possible to dynamically generate the HTML that is served to the browser.

CGI was the original way to dynamically generate HTML but it was a pain to work with.

There are tons of options out there now. I would guess that PHP is by far the most prolific. ASP is very popular. ColdFusion used to be very popular.

I prefer JSP and Servlets because I've been writing Java for nearly 10 years but you almost have to run your own server if you want to develop in JSP. Very few ISPs support it.