Results 1 to 5 of 5

Thread: dynamic anylink vertical menu

  1. #1
    Join Date
    Feb 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation dynamic anylink vertical menu

    Hello. I need some help about the anylink vertical menu . This is the problem: the links (as the amount of links as the links theyselves) need to be declared in a static way, it means, in the begining of the javascript code. What I need is a to create the links dynamically in the html code (as Anylink CSS menu does) because I have a list of links, where each one has must have a menu with its own links.

    Thanks
    Bye!!!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The menus are declared in the script code, you can add as many as you need (from the demo):

    Code:
    //Contents for menu 1
    var menu1=new Array()
    menu1[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a>'
    menu1[1]='<a href="http://www.freewarejava.com">Freewarejava.com</a>'
    menu1[2]='<a href="http://codingforums.com">Coding Forums</a>'
    menu1[3]='<a href="http://www.cssdrive.com">CSS Drive</a>'
    menu1[4]='<a href="http://tools.dynamicdrive.com/imageoptimizer/">Image Optimizer</a>'
    
    
    //Contents for menu 2, and so on
    var menu2=new Array()
    menu2[0]='<a href="http://www.javascriptkit.com/cutpastejava.shtml">Free JavaScripts</a>'
    menu2[1]='<a href="http://www.javascriptkit.com/javaindex.shtml">JavaScript tutorials</a>'
    menu2[2]='<a href="http://news.bbc.co.uk">JavaScript Reference</a>'
    menu2[4]='<a href="http://www.javascriptkit.com/java/">Java Applets</a>'
    menu2[3]='<a href="http://www.javascriptkit.com/dhtmltutors/">DHTML & CSS</a>'
    menu2[4]='<a href="http://www.javascriptkit.com/howto/">Design Tutorials</a>'
    One thing people often miss is that the array names must agree with the individual menu item declarations. And that if an apostrophe is used inside an item, it must be escaped:

    Code:
    menu2[4]='<a href="http://www.javascriptkit.com/howto/">Designer\'s Tutorials</a>'
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes, I know that in the anylink vertical menu (http://www.dynamicdrive.com/dynamici...nkvertical.htm)
    the menus are declared in the code, but what I need is something like anylink CSS menu does (http://www.dynamicdrive.com/dynamici...ylinkcss.htm):

    HTML Code:
    <!--1st anchor link and menu -->
    
    <a href="http://www.dynamicdrive.com" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'anylinkmenu1')">Anchor Link</a>   
                                                        
    <div id="anylinkmenu1" class="anylinkcss">
    
    <a href="http://www.dynamicdrive.com/">Dynamic Drive</a>
    <a href="http://www.cssdrive.com">CSS Drive</a>
    <a href="http://www.javascriptkit.com">JavaScript Kit</a>
    <a href="http://www.codingforums.com">Coding Forums</a>
    <a href="http://www.javascriptkit.com/jsref/">JavaScript Reference</a>
    
    </div>
    The menus are declared in the html code itself. This is useful because I need to pass some parameters along the link, but I want to do it with hte vertical menu. This is a sample code of what I want:

    PHP Code:
    while(/*some condition*/)
    {
    echo 
    '<a href="#" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, \''.$id_menu.'\')">'.$rowmat->nombre_reactivo.'</a>';

    echo 
    '<a href=insertar_ficha.php?codigo='.$rowmat->codigo_reactivo.'>Insertar Ficha</a>';
    echo 
    '<a href=modificar_ficha.php?codigo='.$rowmat->codigo_reactivo.'>Modificar Ficha</a>';
    echo 
    '<a href=eliminar_ficha.php?codigo='.$rowmat->codigo_reactivo.'>Eliminar Ficha</a>';
    echo 
    '<a href=ver_ficha.php?codigo='.$rowmat->codigo_reactivo.'>Ver Ficha</a>';

    echo 
    '</div>';



  4. #4
    Join Date
    Feb 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes I know that, but what I need is something like anylink CSS menu (http://www.dynamicdrive.com/dynamici...anylinkcss.htm) does (to create the links in the html code, not in the javascript):

    HTML Code:
    <!--1st anchor link and menu -->
    
    <a href="http://www.dynamicdrive.com" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'anylinkmenu1')">Anchor Link</a>   
                                                        
    <div id="anylinkmenu1" class="anylinkcss">
    
    <a href="http://www.dynamicdrive.com/">Dynamic Drive</a>
    <a href="http://www.cssdrive.com">CSS Drive</a>
    <a href="http://www.javascriptkit.com">JavaScript Kit</a>
    <a href="http://www.codingforums.com">Coding Forums</a>
    <a href="http://www.javascriptkit.com/jsref/">JavaScript Reference</a>
    
    </div>
    I nedd to do it that way because I have to pass some parameters along th links. Here there´s a sample code code of what I want to do with the vertical menu:

    PHP Code:
    while(/*some condition*/)
    {
    echo 
    '<a href="#" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, \''.$id_menu.'\')">'.$rowmat->nombre_reac.'</a>';

    echo 
    '<div id="uniqueID" class="anylinkcss">';
                    
    echo 
    '
    <a ref=insertar_ficha.php?codigo='
    .$rowmat->codigo_reactivo.'>Insertar Ficha</a>
    <a href=modificar_ficha.php?codigo='
    .$rowmat->codigo_reactivo.'>Modificar Ficha</a>
    <a href=eliminar_ficha.php?codigo='
    .$rowmat->codigo_reactivo.'>Eliminar Ficha</a>
    <a href=ver_ficha.php?codigo='
    .$rowmat->codigo_reactivo.'>Ver Ficha</a>';

    echo 
    '</div>';


  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Why can't you echo the code out into the script?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •