tetzloff
08-23-2006, 07:16 PM
Hello Everyone,
Let me get straight to it. I am using the dhtml menu that is located on dynamic drive. It is the Dhtml Drop down menu. Here is a link to the page I am working on for reference.
http://thebrandartist.thestudioproject.com/v1.3/main.php
What I need to be able to do it have the last menu item child, "Life" align to the right of the menu instead of the left like it does normally. I know this should be easy, but I am new to javascript and desperately need some help from all of you. :) First I e-mailed the creator of the script, and since Im am new to this scripting I couldnt get it right.
Here is what the creator replied.
The position of the menu is set by this line in at_show_aux function:
c.style.left = left+'px';
You can change it like this:
c.style.left = (left-100)+'px';
This will shift menu to the left.
To know which menu to shift, you can check ids:
if (p.id = "<parent menu id>") ...
That does align them the opposite direction when I simplely replace those two lines of code. But what I need is for the last menu item only to align the opposite way, and I cannot figure out the if statement that I would need to be able to accomplish this.
The div id of the Life menu parent is: life_parent
Here is the actual javascript code for the menus:
<script>
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+0 : 0;
var left = (c["at_position"] == "x") ? p.offsetWidth +0 : 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'", 30);
}
// ----- 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;
}
}
Thank you everyone in advance. I appreciate any help that can be given.
-Tyler
Let me get straight to it. I am using the dhtml menu that is located on dynamic drive. It is the Dhtml Drop down menu. Here is a link to the page I am working on for reference.
http://thebrandartist.thestudioproject.com/v1.3/main.php
What I need to be able to do it have the last menu item child, "Life" align to the right of the menu instead of the left like it does normally. I know this should be easy, but I am new to javascript and desperately need some help from all of you. :) First I e-mailed the creator of the script, and since Im am new to this scripting I couldnt get it right.
Here is what the creator replied.
The position of the menu is set by this line in at_show_aux function:
c.style.left = left+'px';
You can change it like this:
c.style.left = (left-100)+'px';
This will shift menu to the left.
To know which menu to shift, you can check ids:
if (p.id = "<parent menu id>") ...
That does align them the opposite direction when I simplely replace those two lines of code. But what I need is for the last menu item only to align the opposite way, and I cannot figure out the if statement that I would need to be able to accomplish this.
The div id of the Life menu parent is: life_parent
Here is the actual javascript code for the menus:
<script>
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+0 : 0;
var left = (c["at_position"] == "x") ? p.offsetWidth +0 : 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'", 30);
}
// ----- 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;
}
}
Thank you everyone in advance. I appreciate any help that can be given.
-Tyler