Jump to content


Dropdown help.


4 replies to this topic

#1 Nike

    Young Padawan

  • Members
  • Pip
  • 204 posts
  • Location:Ohio
  • Interests:Controlling the human and and duck race.

Posted 01 October 2006 - 11:01 AM

I have a dropdown. It's a basic dropdown. But I want to add an expansion on to it. So, could you help me?

My code is this.

index.php

<a href="#"><img src="images/home.gif" alt="Home" border="0" /></a>
<a href="#"><img src="images/jokes.gif" alt="Jokes" border="0" id="menu_parent" style="margin-left: 8px;" /></a>
<a href="#"><img src="images/faq.gif" border="0" style="margin-left: 8px;" alt="FAQ" /></a>
<a href="#"><img src="images/links.gif" border="0" style="margin-left: 8px;" alt="Links" /></a>
<div id="menu_child"><a href="#">Fat momma</a><a href="#">Ugly momma</a><a href="#">stupid momma</a></div>
<script type="text/javascript">
at_attach("menu_parent", "menu_child", "hover", "y", "pointer");
</script>

Js.php

// <script>




// ----- Popup Control ---------------------------------------------------------

function at_display(x)
{
win = window.open();
for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- Show Aux -----

function at_show_aux(parent, child)
{
var p = document.getElementById(parent);
var c = document.getElementById(child);

var top = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

for (; p; p = p.offsetParent)
{
top += p.offsetTop;
left += p.offsetLeft;
}

c.style.position = "absolute";
c.style.top = top +'px';
c.style.left = left+'px';
c.style.visibility = "visible";
}

// ----- Show -----

function at_show()
{
p = document.getElementById(this["at_parent"]);
c = document.getElementById(this["at_child" ]);

at_show_aux(p.id, c.id);

clearTimeout(c["at_timeout"]);
}

// ----- Hide -----

function at_hide()
{
c = document.getElementById(this["at_child"]);

c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ----- Click -----

function at_click()
{
p = document.getElementById(this["at_parent"]);
c = document.getElementById(this["at_child" ]);

if (c.style.visibility != "visible") at_show_aux(p.id, c.id);
else c.style.visibility = "hidden";

return false;
}

// ----- Attach -----

// PARAMETERS:
// parent - id of visible html element
// child - id of invisible html element that will be dropdowned
// showtype - "click" = you should click the parent to show/hide the child
// "hover" = you should place the mouse over the parent to show
// the child
// position - "x" = the child is displayed to the right of the parent
// "y" = the child is displayed below the parent
// cursor - Omit to use default cursor or check any CSS manual for possible
// values of this field

function at_attach(parent, child, showtype, position, cursor)
{
p = document.getElementById(parent);
c = document.getElementById(child);

p["at_parent"] = p.id;
c["at_parent"] = p.id;
p["at_child"] = c.id;
c["at_child"] = c.id;
p["at_position"] = position;
c["at_position"] = position;

c.style.position = "absolute";
c.style.visibility = "hidden";

if (cursor != undefined) p.style.cursor = cursor;

switch (showtype)
{
case "click":
p.onclick = at_click;
p.onmouseout = at_hide;
c.onmouseover = at_show;
c.onmouseout = at_hide;
break;
case "hover":
p.onmouseover = at_show;
p.onmouseout = at_hide;
c.onmouseover = at_show;
c.onmouseout = at_hide;
break;
}
}


Thanks.

For a live preview www.nike.setrahosting.net/yomama hover over Jokes.

#2 Nike

    Young Padawan

  • Members
  • Pip
  • 204 posts
  • Location:Ohio
  • Interests:Controlling the human and and duck race.

Posted 02 October 2006 - 07:56 AM

Anyone?

#3 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 02 October 2006 - 06:06 PM

'You want to add an expansion to it...' Sorry but i have no idea what your trying to achieve, adding an expansion could be anything...

please be more detailed

#4 Nike

    Young Padawan

  • Members
  • Pip
  • 204 posts
  • Location:Ohio
  • Interests:Controlling the human and and duck race.

Posted 02 October 2006 - 06:30 PM

Alright, like so if I hover over another block, it goes to another drop down.

http://www.dynamicdr...mmenu/index.htm

Like that horizontal one. hover over the forth one over. and forth one down. Like.

There code is so sloppy that you can't implent it at all. So I must create my own. So please.. help.

[Item 1] [Item 2] [Item 3] [etc..]
[Drop 1]
[Drop 2] -> [Expansion 1]
[Drop 3] [Expansion 2]
[Expansion 3]

Edited by Nike, 03 October 2006 - 04:23 PM.


#5 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 03 October 2006 - 05:12 PM

ah, that makes sence. I'd do it with CSS rather than javascript tho. Read this tutorial, it will help ;)

http://www.seoconsul...nus/horizontal/





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users