SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    menu in javascript

    Hi!

    I have found a great menu made in javascript.Unfortunately i'm no good in javascript..

    My problem is that i want to get the name on the levels "top","sub" and "sub2" and the url that it refers to straight from a mysql database.

    As it is at the moment i have to add code every time.(when i add a post in the database)

    Here some of the code:

    slideMenu.makeMenu('top','Here is some text')
    slideMenu.makeMenu('sub','More text')
    slideMenu.makeMenu('sub2','Visit this link','http://www.test.no')
    slideMenu.makeMenu('sub2','Or this link','http://www.vg.no')
    slideMenu.makeMenu('sub','Another option')
    slideMenu.makeMenu('sub2','Click this option','http://www.site.com')
    slideMenu.makeMenu('top','blablabla')


    Hope someone can help me.Guess I need to use an array in some way.

    If you need more code just say so..

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use php (or whatever) to get info from mysql and print the lines
    slideMenu.makeMenu(...) ?

  3. #3
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hinux
    As it is at the moment i have to add code every time.(when i add a post in the database)

    Here some of the code:

    slideMenu.makeMenu('top','Here is some text')
    slideMenu.makeMenu('sub','More text')
    slideMenu.makeMenu('sub2','Visit this link','http://www.test.no')
    slideMenu.makeMenu('sub2','Or this link','http://www.vg.no')
    slideMenu.makeMenu('sub','Another option')
    slideMenu.makeMenu('sub2','Click this option','http://www.site.com')
    slideMenu.makeMenu('top','blablabla')
    If you're using PHP and MySQL:
    PHP Code:
    <?
    require ("connect.php");
    $query="SELECT label, text from thetable";
    $result=mysql_query($query);
    print <<< END
    <html>
    <body>
    <script languare="text/javascript")>
    END;
    while (
    $row=mysql_fetch_assoc($result)){
    echo 
    "slideMenu.makeMenu('$row[label]','$row[text]')\n";
    }
    print <<< END
    </script>
    </body>
    </html>
    END;
    ?>
    I like to see new menus. Can you show me what this slideMenu looks like?

    D.

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    of course...i will post the link in a few minutes.
    Thank you..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •