1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

JavaScript Menu Options

Discussion in 'Web Development' started by knightknight, Aug 27, 2009.

  1. knightknight

    knightknight New Member

    Hi, I'm using the first charity template, and at the top there's a few "Menu" links which I've changed them to link to several pages. I'd like to have the choices in one file, and have each page just pull from that file to display the choices.

    The code from the index file looks like this:
    <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="mission.html">About Us</a></li>
    <li><a href="greenupdates.html">Meetings</a></li>
    <li><a href="memberlist.html">Contact us</a></li>
    </ul>

    So what I started with was a javascript file called menu.js and inserted this code into my index file:
    <script type="text/javascript" src="menu.js">
    </script>

    I used some similiar code to insert random green tips from a javascript file, that worked rather well, but when translating this idea to the menu, it didn't quite do what I was hoping.
    code from menu.js:
    document.write("<ul><li><a href="index.html">Home</a></li><li><a href="mission.html">Mission Statement</a></li><li><a href="greenupdates.html">Green Updates</a></li><li><a href="memberlist.html">Contact us</a></li></ul>");

    This didn't quite look right. Anyone have any ideas on getting this to work? Or a different approach?

    I'd really appreciate it.
     
  2. bmcoll3278

    bmcoll3278 New Member

    When your menus are done with java script you must remember it is a client side language
    That means that a search engine can not see or follow the links in that menu.

    I would use a php file.

    Code:
    <?php
    echo"<ul>
    <li><a href=\"index.html\">Home</a></li>
    <li><a href=\"mission.html\">About Us</a></li>
    <li><a href=\"greenupdates.html\">Meetings</a></li>
    <li><a href=\"memberlist.html\">Contact us</a></li>
    </ul>";
    you can ad or remove as many links as you want just remember the \ before the " in your links this is a must with php.

    Save the above code as menu.php

    You must change the file ex on your pages to .php instead of html

    then to call the menu in a page use this <?php include ("menu.php"); ?>

    if you look here it will show you how to use the .htaccess file so that your links can still say .html even though your pages are .php
     
  3. knightknight

    knightknight New Member

    in order to use php though doesn't the server have to support php? my issues is that this is going to be posted on a intranet system for a nonprofit company...
     
  4. bmcoll3278

    bmcoll3278 New Member

    oh sorry yea your right.

    I dont know javascript well
     
  5. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    maybe if you put in some dropdowns it might work but you do not have any!
     
  6. lenchnikin

    lenchnikin New Member

    It works when I load nnCron as an ordinary application using -ns , allthough the firsttime, the menu cant show my language after restart its own restart, but if I quit and start it myself with -ns, the language switch can works.

    Anyway, it works in ordinary application mode. But how to let nncron use config in its own directory?

    The service mode still doesnt work with build 1120. And Im using my own computer, not a terminal.
     
  7. GDSweb.ca

    GDSweb.ca Moderator/Developer

    Try this out....


    Hey dude, after reading your post (and reading it a few more times) I think I know what your after.

    In order to do this with a .js you will need to write yourself some code, and unless you're very fimiliar in writing JS you'll need some help.

    The easier path for you to take would be ishkey's suggestion, a dropdown menu.

    Here is a solution that you could try out:

    In the Zip attached to my post you will find two files, one a CSS file, and the other a chunk of HTML. Now this is a dropdown menu that is not a .js file or a php file, it's simply a css driven dropdown!

    Insert the CSS into your current stylesheet, and insert the HTML into your templates code, do some tweeking on both ends and you will have a scriptless dropdown menu that you can put unlimited links into....

    Hope that helps.:)
     

    Attached Files:

  8. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    GDSweb.ca has solution for you, you should use it.
    what does nnCron have to do with your coding??? It's a is a small power scheduler nothing more. If you are using your own computer like most people do, just open the file up in your browser to view it.
    "Terminal" like in terminal server !!!