PDA

View Full Version : dynamic anylink vertical menu



coruscantcity
03-23-2006, 02:00 PM
Hello. I need some help about the anylink vertical menu :confused: . 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!!!

jscheuer1
03-23-2006, 04:32 PM
The menus are declared in the script code, you can add as many as you need (from the demo):


//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:


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

coruscantcity
03-27-2006, 02:19 PM
Yes, I know that in the anylink vertical menu (http://www.dynamicdrive.com/dynamicindex1/anylinkvertical.htm)
the menus are declared in the code, but what I need is something like anylink CSS menu does (http://www.dynamicdrive.com/dynamicindex1/anylinkcss.htm):



<!--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:



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>';

}

coruscantcity
03-27-2006, 02:54 PM
Yes I know that, but what I need is something like anylink CSS menu (http://www.dynamicdrive.com/dynamicindex1/anylinkcss.htm) does (to create the links in the html code, not in the javascript):



<!--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:



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>';
}

jscheuer1
03-27-2006, 04:38 PM
Why can't you echo the code out into the script?