473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

problem in slide down menu

254 100+
hello friends

I am new to javascript and I have a problem. I am giving the code
[HTML]<!-- Paste this code into the CSS section of your HTML document -->
<html>
<head>
<style type="text/css">[/HTML]
Expand|Select|Wrap|Line Numbers
  1. .menu {
  2.  position:relative;
  3.  background-color:gold;
  4.  border:1px solid darkblue;
  5.  width:150;
  6.  font-size:11px;
  7.  font-family:verdana;
  8.  font:bold;
  9.  position:absolute;
  10.  cursor:se-resize;
  11. }
  12.  
  13. .item_panel {
  14.   width:150;
  15.   border-left:1px solid darkblue;
  16.   border-right:1px solid darkblue;
  17.   clip:rect(0,150,0,0);
  18.   position:absolute;
  19. }
  20.  
  21. .item_panel a {
  22.  text-decoration:none;
  23.  color:black;
  24.  cursor:hand;
  25. }
  26.  
  27. .item {
  28.  background-color:lightyellow;
  29.  width:148;
  30.  font-size:10px;
  31.  font-family:verdana;
  32. }
  33.  
  34.  
Expand|Select|Wrap|Line Numbers
  1. </style>
  2. <script language="javascript">
Expand|Select|Wrap|Line Numbers
  1. var height = 20; // height of the menu headers
  2. var iheight = 15; // height of the menu_items
  3.  
  4. var bgc = "lightyellow" // background color of the item
  5. var tc = "black" // text color of the item
  6.  
  7. var over_bgc = "silver";
  8. var over_tc = "red";
  9.  
  10. var speed = 0;
  11. var timerID = "";
  12. var N = (document.all) ? 0 : 1;
  13. var width = 152
  14. var self_menu = new Array();
  15.  
  16. function write_menu() {
  17.   smc = 0; // count the position of the self_menu
  18.   document.write("<div style='position:absolute'>");
  19.   mn = 0;
  20.   mni = 1;
  21.   start = -1;
  22.  
  23.   for(i=0;i<Link.length;i++) {
  24.    la = Link[i].split("|");
  25.    if (la[0] == "0") {
  26.     if(start == 0) {
  27.       document.write("</div>");
  28.       h =  csmc * iheight;
  29.       tmn = mn; //-h
  30.       self_menu[smc] = new Array(tmn,h,0,-2);
  31.       smc++;
  32.       mn--;
  33.      }
  34.      csmc = 0;
  35.     document.write("<div class='menu' style='top:"+mn+";height:"+height+"' id='down"+smc+"' onclick='pull_down("+smc+","+mni+")'> "+ la[1] + "</div>");
  36.     self_menu[smc] = new Array(mn,height,0,mni);
  37.     smc++;
  38.     mni++;
  39.     mn+=height;
  40.     start = 1;
  41.    } else {
  42.     if(start == 1) {
  43.       if(N)mn+=2;
  44.        document.write("<div class='item_panel' id='down"+smc+"' style='top:"+mn+"'>");
  45.        start = 0;
  46.      }
  47.  
  48.     document.write("<a href='"+la[2]+"'");
  49.     if (la[3] != "") document.write(" target='" + la[3] + "' ");
  50.     document.write("><div class='item' id='d"+i+"' style='height:"+iheight);
  51.     if (N) document.write(";width:150");
  52.     document.write("' onmouseover='color(this.id)' onmouseout='uncolor(this.id)'>  "+ la[1] + "</div></a>");
  53.     csmc++;
  54.    }
  55.   }
  56.   if (start == 0) {
  57.      document.write("</div>");
  58.      h =  csmc * iheight;
  59.      tmn = mn + 5; //-h
  60.      self_menu[smc] = new Array(tmn,h,0);
  61.      name = "down" + (self_menu.length-1);
  62.      obj = document.getElementById(name);
  63.      obj.style.borderBottomColor = "darkblue";
  64.      obj.style.borderBottomWidth = 1;
  65.      obj.style.borderBottomStyle = "solid";
  66.    }
  67.   document.write("</div>");
  68. }
  69.  
  70. function color(obj) {
  71.  document.getElementById(obj).style.backgroundColor = over_bgc;
  72.  document.getElementById(obj).style.color = over_tc
  73. }
  74.  
  75. function uncolor(obj) {
  76.  document.getElementById(obj).style.backgroundColor = bgc;
  77.  document.getElementById(obj).style.color = tc
  78. }
  79.  
  80. function pull_down(nr,c) {
  81.  if (timerID == "") {
  82.  to = self_menu[nr+1][1]
  83.  begin = nr + 2;
  84.  if (timerID != "") clearTimeout(timerID);
  85.  if (self_menu[nr+1][2] == 0) {
  86.   self_menu[nr+1][2] = 1;
  87.   if(nr == self_menu.length-2) {to++;}
  88.   epull_down(begin,to,0);
  89.  } else {
  90.   to = 0;
  91.   self_menu[nr+1][2] = 0;
  92.   name = "down"+(nr+2);
  93.   open_item = 0;
  94.   for(i=0;i<nr;i++) {
  95.    if(self_menu[i][2] == 1)
  96.     {open_item += self_menu[i][1];
  97.     }
  98.   }
  99.   if (N == false) {open_item-= (c*1)};
  100.   if (nr== self_menu.length-2) {val = self_menu[self_menu.length-1][1];to=-1;}
  101.   else  val = parseInt(document.getElementById(name).style.top) -(open_item)-(c*height);
  102.   epull_up(begin,to,val);
  103.   }
  104.   }
  105. }
  106.  
  107. function epull_down(nr,to,nowv) {
  108.  name = "down" + (nr-1);
  109.  obj = document.getElementById(name).style.clip = "rect(0,"+width+","+(nowv+1)+",0)";
  110.  for (i=nr;i<self_menu.length;i++) {
  111.   name = "down" + i;
  112.   obj = document.getElementById(name);
  113.   obj.style.top = parseInt(obj.style.top)+1;
  114.  }
  115.  nowv++;
  116.  if(nowv < to) timerID = setTimeout("epull_down("+nr+","+to+","+nowv+")",speed);
  117.  else timerID = ""; 
  118. }
  119.  
  120. function epull_up(nr,to,nowv) {
  121.  name = "down" + (nr-1);
  122.  obj = document.getElementById(name).style.clip = "rect(0,"+width+","+nowv+",0)";
  123.  for (i=nr;i<self_menu.length;i++) {
  124.   name = "down" + i;
  125.   obj = document.getElementById(name);
  126.   obj.style.top = parseInt(obj.style.top)-1;
  127.  }
  128.  nowv--;
  129.  if(nowv > to) timerID = setTimeout("epull_up("+nr+","+to+","+nowv+")",speed);
  130.  else timerID = "";
  131. }
  132.  
  133. function startup(nr) {
  134.  write_menu();
  135.  if (nr != 0) {
  136.  for(i=0;i<self_menu.length;i++)
  137.  {
  138.   if(self_menu[i][3] == nr) pull_down(i,nr)
  139.   i==self_menu.length;
  140.  }
  141.  }
  142. }
[HTML]</script>
</head>
<body>







<table><tr><td>
<table width=150><tr><td height="70">
<script language="JavaScript">
//Link[nr] = "position [0 is menu/1 is item],Link name,url,target (blank|top|frame_name)"
var Link = new Array();
Link[0] = "0|Home";
Link[1] = "1|Home|http://#|";
Link[2] = "1|More Scripts|http#|";
Link[3] = "1|Contact|http://#/contact-us.html|";
Link[4] = "1|Traffic|http://#|";
Link[5] = "0|Access";
Link[6] = "1|Login|Login.asp|";
Link[7] = "1|Logout|Logout.asp|"
Link[8] = "0|Scripts";
Link[9] = "1|Asp|http://#|";
Link[10] = "1|JavaScript|http://#|";
Link[11] = "0|Links";
Link[12] = "1|JavaScript sites|http://#|blank";

startup(4);
</script>
</td></tr></table></td></tr></table></body></html>
[/HTML]


so the problem is that if you run this you will get heading and submenu uder that.
what I wanted that I want to go to one level more depth means when I click say More Scripts it should show java, c and so on.

So where do I need to change in this script for that

please help me out.
Dec 6 '07 #1
5 2589
acoder
16,027 Expert Mod 8TB
You're using the following format:
Expand|Select|Wrap|Line Numbers
  1. //Link[nr] = "position [0 is menu/1 is item],Link name,url,target (blank|top|frame_name)"
so add a new position '2' for submenu and perhaps add a 'parent value' to refer to its parent submenu.

Have you written this yourself?
Dec 6 '07 #2
mukeshrasm
254 100+
You're using the following format:
Expand|Select|Wrap|Line Numbers
  1. //Link[nr] = "position [0 is menu/1 is item],Link name,url,target (blank|top|frame_name)"
so add a new position '2' for submenu and perhaps add a 'parent value' to refer to its parent submenu.

Have you written this yourself?

Hi

No, I have not written this code, that's why I am facing problem. So where I have to modify the code if You can please specify for me. and how?

Thanks
Dec 7 '07 #3
acoder
16,027 Expert Mod 8TB
No, I have not written this code, that's why I am facing problem. So where I have to modify the code if You can please specify for me. and how?
Unless there's something really awesome about this menu code, why not just use a menu script which already has another level?
Dec 7 '07 #4
mukeshrasm
254 100+
Unless there's something really awesome about this menu code, why not just use a menu script which already has another level?
Did not got what you want to say so please specify the things. Which Menu script you are talking about?

Thanks
Dec 7 '07 #5
acoder
16,027 Expert Mod 8TB
Not one in particular, but you could try something like this - more CSS-based rather than JavaScript.
Dec 10 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
0
by: Czechfish | last post by:
My files are located here: HTML & SWF FLA I am trying to create a multi-tier drop down menu, but I can't get it to work. Maintime line, frame 1 - loads a mc. When you rollover the mc, this...
7
by: Joe | last post by:
usually slide bars move by "jumps" while scrolling which looks not nice. I came accress slide bar with price menu, ewnt through script/web source code, and could not find anything that would case...
1
by: crazy works | last post by:
hello guys, i have problem in the scroll bar on my css code , i am trying to use that css menu from that link http://www.cssplay.co.uk/menus/slide_fly.html it actually works very good but i want...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.