PDA

View Full Version : Dropdown help



Nike
10-01-2006, 07:49 PM
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.

Nike
10-02-2006, 12:54 PM
Anyone?

Nike
10-03-2006, 09:05 PM
If you don't understand. Like this.

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

mburt
10-04-2006, 12:06 AM
But I want to add an expansion on to it

What do you mean by expansion.

Nike
10-04-2006, 12:10 AM
...
[Item 1] [Item 2] [Item 3] [etc..]
[Drop 1]
[Drop 2] -> [Expansion 1]
[Drop 3] [Expansion 2]
[Expansion 3]

blm126
10-04-2006, 12:53 AM
If you could show what the code above does in a live demo we will be able to help better.

Nekomajin
02-16-2007, 10:40 PM
Hi!

I've downloaded this script too, but I have a problem.
I want to make a menu system, but I can't create more than one main menu.
Can you help me, what I should do?
http://img.photobucket.com/albums/v654/Nekomajin/help/dropdown_scr.jpg