dropdown menu

They have: 7 posts

Joined: Oct 2001

Is it possible to have the same drop down menu appear on different pages without out using frames, so that when the content needs changed or updated this only has to be done once and not on each page. I think it can be done using java but dont know how.

Busy's picture

He has: 6,151 posts

Joined: May 2001

make the form in a seperate file, and name it form.js or something, but do it in javascript, then included the file into your web pages, this way the same form is used on any page you include the form.

page contents blah blah blah

<script type="text/javascript" src="form.js"></script>
more page contents blah blah blah

They have: 7 posts

Joined: Oct 2001

I saved this as menu1.js

Group A
Group B
Group C

then tried to open it on the page but it didn't work.Do I need anything before the select tag of anything else on the page. I know its something simple i'm doing wrong but if you could tell me how the script should look it would be a great help.

Busy's picture

He has: 6,151 posts

Joined: May 2001

The contents of the .js file has to be written in javascript

document.write('');
....

watch out for your quotes thou, you can always escape them by using a "\" before them, like:

document.write("");

They have: 7 posts

Joined: Oct 2001

I really appreciate all your help and patience, but I'm still not getting it to work. This is my first time trying to use .js files and was wondering if you could write the script so that I could just copy and paste it and that way I would be able to understand how it all works.

Thanks again

They have: 2 posts

Joined: Oct 2001

This is what I use on my site:

<!--
function makearray() {
var args = makearray.arguments;
    for (var i = 0; i < args.length; i++) {
    this[i] = args[i];
    }
this.length = args.length;
}
var pages = new makearray("Site Navigation",
                            "Page 1 of your site",
                             "Page 2 of your site",
                             "Page 3 of your site");

var urls = new makearray("",
"page1.htm",
"page2.htm",
"page3.htm");

function goPage(form) {
i = form.menu.selectedIndex;           
    if (i != 0) {
    window.location.href = urls[i]; 
    }
}

//-->
'

Copy the above code and paste it into Notepad, then save it with a .js extension. (I named mine nav.js)

Next copy and paste the following into a new file and name it something with a .js extension. (I named mine nav2.js)

<!--
document.write('<FORM><SELECT NaME = "menu" onChange = "goPage(this.form)">');
    for (var i = 0; i < pages.length; i++) {
    document.write('<OPTION>' + pages[i]);
    }
document.write('</SELECT></FORM>');

//-->
'

Then if you want to call them just place the following in your HTML where ever you want your drop menu to appear:

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

Of course please do not forget to change "whatever_you_named_the_first_part" and "whatever_you_named_the_second_part" to what you actually named them. Smiling

They have: 7 posts

Joined: Oct 2001

Tank you everyone very much

They have: 38 posts

Joined: Oct 2001

ssi

whether its shtml php or asp

is what i would o make a table with an include .txt php whatever

and have your menu be this file
that was on all your pages just change the one file for the menu to change on all of them

I do not use netscape nor care if my stuff works or doesnt in it.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.