SitePoint Sponsor

User Tag List

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

    using php to put variables into a 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
    SitePoint Enthusiast
    Join Date
    Aug 2000
    Location
    Catalonia
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to echo the javascript using <?php .... javascript code with \' or \" ... ?>

    PHP Code:
    slideMenu.makeMenu('top','$row[text1]')
    slideMenu.makeMenu('sub','$row[text2]')
    slideMenu.makeMenu('sub2','$row[text3a]','http://www.test.no')
    slideMenu.makeMenu('sub2','$row[text3b]','http://www.vg.no')
    .... 
    Hope it helps

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you....look forward to try it out..

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm..im having troble with this.

    I've made the queries,but cant get my values inserted the way i want it.

    Can someone please help me??

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Can you post some code?

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The javascript code is similar to the one above.
    Here is some of my code:
    PHP Code:
    $query_heis "SELECT Heis_navn FROM Heis";
    $query_mast1 "SELECT Mast_navn FROM Mast where Mast_ID like '1_______'";
    $query_mast2 "SELECT Mast_navn FROM Mast where Mast_ID like '2_______'";
    $query_mast3 "SELECT Mast_navn FROM Mast where Mast_ID like '3_______'";

    $heis mysql_query($query_heis) or die("SELECT query failed");
    $mast1 mysql_query($query_mast1) or die("SELECT query failed");
    $mast2 mysql_query($query_mast2) or die("SELECT query failed");
    $mast3 mysql_query($query_mast3) or die("SELECT query failed"); 
    $heis is my top level
    $mast1 is my first sublevel
    $mast2 is my second sublevel

    I also have a sublevel2.hard to explain the structure.

    I need the first post in $heis,then the entire $mast1 as a sublevel.Then the second post in $heis and $mast2 as the sublevel.

    Do you make any sense of this?

  7. #7
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there anybody out there?

    I would really like my menu to become 100% dynamic..

    Grateful for any response!!

  8. #8
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having exactly the same problem with a javascript menu I like a lot but I'm unable to use it with php. Could you give me the url of the page you got the menu to see if I can do something with it.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  9. #9
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The version i'm working on is here:
    http://hinux.hin.no/~mortenb/skole/h...ngmenu2605.php

  10. #10
    ********* Addict DLG_1's Avatar
    Join Date
    Jun 2000
    Location
    Texas, USA
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wish I could help; however, you need to post the code that performs the interaction.

  11. #11
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can this help you?
    this is the javascript-file.

    http://hinux.hin.no/~mortenb/skole/h...3/slidemenu.js

    If not ask again..

  12. #12
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I meant the url to where you actually got the javascript menu.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  13. #13
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that url is three posts above in this thread...

  14. #14
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok... I've got some scripts from www.javascript.com. That's want I need to know, the site from where you got that script.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  15. #15
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Norway
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok...great.


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
  •