Forum Moderators: open

Message Too Old, No Replies

Linking a javascript document to HTML pages

         

gooders2274

6:45 pm on Sep 30, 2006 (gmt 0)

10+ Year Member



Sorry I am very new to javascript, I have written my site in HTML and CSS but I have created a drop down menu which links to about 30 pages within my site. Originally it was only available on the homepage but I would like to have it at the top of every page.

Problem is, when I add new pages to my site I dont want to update EVERY drop down box on every page? Is there an easy way of doing this please.? I assume I can create a javascript file seperate file and link it to my pages so that every time I update the drop down box on the main file it automatically updates on every page, I just have no idea ow I do this or where I would need to place the javascript within the HEAD and BODY of each page so that it displays the updated version each time;

This is the code I have used to create the drop down menu;

<form name="form1" method="post">

<b>Select</b>

<select name="dd1" size="1">
<option value="http://www.url.co.uk/w.htm">W</option>
<option value="http://www.url.co.uk/x.htm">X</option>
</select>

<input type="button"
onclick=
"location =
document.form1.dd1.options
[document.form1.dd1.selectedIndex].value;"
value="GO">

</form>

and I think this goes into the body section where I want the box to appear
<p class="navtitle">Select<script language="javascript" type="text/javascript">document.write(dropdown)</script>

Thanks in advance

gooders2274

8:06 pm on Sep 30, 2006 (gmt 0)

10+ Year Member



UPDATE

I have created an external menu.js file using notepad and uploaded it to my ftp, i have then typed the following into the HEAD of my page

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

but nothing seems to be happening, any ideas please..?

Leosghost

9:17 pm on Sep 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



place it like this ..

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

gooders2274

9:29 pm on Sep 30, 2006 (gmt 0)

10+ Year Member



ive tried that, it doesnt work i;m afraid

penders

1:23 am on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What exactly is in your menu.js file?