Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help:Create a dynamic navigation menu

    Hello everyone, I'm not only new on this forum but also to the world of web development(more specifically to the front end development).
    I have some basic knowledge of HTML,CSS but that's it, I have knowledge of Java and considering using this language as back end and now trying to learn things about the front end development, I'm thinking of using html,css and javascript.

    Having said that. I would like to create a dynamic menu, where names are loaded from another list,database etc. Consider the following code:
    Code:
    <li><a href="#">Home</a></li>
        <li><a href="#">Category</a>
            <ul>
                <li><a href="#">Title 1</a></li>
                <li><a href="#">Title 2</a></li>
                <li><a href="#">Title 3</a></li>
            </ul>
    is it possible to replace "title 1,2,3..." with a variable that automatically retrieve names for that section?

    Thank you

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,927
    Thanks
    6
    Thanked 1,040 Times in 1,013 Posts
    Yes but not with HTML or CSS. You said you know Java so you should actually be somewhat familiar with the concept of retreiving contents from an array or something like that because that’s exactly what you need here. This has to be done on the back end with a server-side script. HTML is only there to display and format the contents, not to manipulate them.

  • #3
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, I understand that I can create a servlet and retrieve a list which then can be passed to the HTML page.
    My concern with this solution is the structure of the menu.
    How can I structure it:

    Lets say I have a list with categories and sub elements which I've retrieved in a list:
    Category1
    list1
    list2
    list3

    Category2
    list1
    list2
    list3

    Category3
    list1
    list2
    list3


    How can I structure it in a mega menu style once I have this list? so that it looks like this:

    Home Category Contact
    Category1 Category3
    list1 list1
    list2 list2
    list3 list3
    Category2
    list1
    list2
    list3

    what steps do I need to take so that my list is automatically structured and then I don't need to touch the front end as the list will be automatically sorted.

  • #4
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any advice?

  • #5
    New Coder
    Join Date
    Jun 2013
    Posts
    34
    Thanks
    1
    Thanked 2 Times in 2 Posts
    It may be possible like this,

    First of all, you have to retrieve values from a database.
    <?php
    $con=mysql_connect("host","username","pasword","databasename");
    $Title1=mysql_querry($con, "SELECT Title1 from Table");
    $Title2=mysql_querry($con, "SELECT Title2 from Table");
    $Title3=mysql_querry($con, "SELECT Title3 from Table");
    mysql_close($con);
    echo "<li><a href="#">Home</a></li>";
    echo "<li><a href="#">Category</a>";
    echo "<ul>";
    echo "<li><a href="#">$Title1</a></li>";
    echo "<li><a href="#">$Title2</a></li>";
    echo "<li><a href="#">$Title3</a></li>";
    echo "</ul>";
    ?>
    This is not the exact code; I only want to give you an idea.


  •  

    Posting Permissions

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