Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[REQ] Codes I need..

Status
Not open for further replies.
Joined
Jun 15, 2007
Messages
3,153
Reaction score
1,252
Hello!

I was seeing if anyone had codes for "Drop Down Menu Box". I have searched, but I cannot find exactly what I am looking for. Everything I find is an image > drop down.

I was looking for a code that will allow plain text > drop down.

(Hover over the text & a drop down menu will appear).

Either that, or a code for sub navigation. (Click on plain text (top navigation) > sub navigation will appear in a text box. Anyone willing to help me?

Thank you,
Sean
 
Custom Title Activated
Loyal Member
Joined
Apr 9, 2007
Messages
2,408
Reaction score
256
HTML:
Code:
<ul id="sddm">
<li><a href="#" onmouseover="mopen('m1')" onmouseout="mclosetime()""mclosetime()">example 1</a>
        <div id="m1" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">
        <a href="#">sub 1</a>
        <a href="#">sub 2</a>
        <a href="#">sub 3</a>
        </div>
        </li>
<li><a href="#" onmouseover="mopen('m2')" onmouseout="mclosetime()""mclosetime()">example 2</a>
        <div id="m2" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">
        <a href="#">sub 1</a>
        <a href="#">sub 2</a>
        <a href="#">sub 3</a>
        <a href="#">sub 4</a>
        </div>
        </li>
<li><a href="#" onmouseover="mopen('m3')" onmouseout="mclosetime()""mclosetime()">example 3</a>
        </li>
<li><a href="#" onmouseover="mopen('m4')" onmouseout="mclosetime()""mclosetime()">example 4</a>
        <div id="m4" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">
        <a href="#">sub 1</a>
        <a href="#">sub 2</a>
        <a href="#">sub 3</a>
        <a href="#">sub 4</a>
        </div>
        </li>
</ul>
CSS
Code:
#sddm {
	margin: 0;
	padding: 0;
	z-index: 30;
	}

#sddm li {
	margin: 0;
	padding: 0;
	margin-right:0px;
	list-style: none;
	float:left;
	font: bold 11px arial;
}

#sddm li a {
	display: block;
	margin: 0 1px 0 0;
	padding: 0px 0px;
	width: auto;
	background: #1287b3;
	color: #000;
	text-align: center;
	text-decoration: none;
}

#sddm li a:hover {
	background: #FFF;
}

#sddm div {	
	position:absolute;
	visibility: hidden;
	margin: 0;
	padding: 0;
	background: #1287b3;
	border: 1px solid #000;
	text-align:center;
}

#sddm div a {
	position: relative;
	display: block;
	margin: 0;
	padding: 5px 10px;
	width: auto;
	white-space: nowrap;
	text-align: center;
	text-decoration: none;
	background: #1287b3;
	color: #FFF;
	font: 12px arial;
}

#sddm div a:hover {
	background: #045371;
	color: #FFF;
}
Javascript
Code:
//menu
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
function movepic(img_name, img_src)
   {
   document[img_name].src = img_src;
   }

Example:

(let me clean up the codes for you...) done...
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Apr 9, 2007
Messages
2,408
Reaction score
256
Well plain HTML will never happen.
Since there needs to be some javascript to trigger to show the dropdown + some CSS to hide the divs and later show them.
Well an plain dropdown menu is:

Code:
<ul style="list-style:none;">
<li>example 1
<ul style="list-style:none;"><li>sub 1</li><li>sub 2</li><li>sub 3</li><li>sub 4</li></ul></li>
<li>example 2
<ul style="list-style:none;"><li>sub 1</li><li>sub 2</li><li>sub 3</li><li>sub 4</li></ul></li>
<li>example 3</li>
<li>example 4
<ul style="list-style:none;"><li>sub 1</li><li>sub 2</li><li>sub 3</li><li>sub 4</li></ul></li>
</ul>
 
Last edited:
Joined
Sep 10, 2006
Messages
2,817
Reaction score
1,417
Sure you can do it with css only, simply do somrthing like li ul { display: none; } li:hover ul { display: block; } on the other hand, why wouldn't you want to use js, much more neat/compatible/dynamic
 
Custom Title Activated
Loyal Member
Joined
Apr 9, 2007
Messages
2,408
Reaction score
256
Sure you can do it with css only, simply do somrthing like li ul { display: none; } li:hover ul { display: block; } on the other hand, why wouldn't you want to use js, much more neat/compatible/dynamic

This is true but old IE is not supporting this.
And you have to think about IE users ;)
 
Joined
Jun 15, 2007
Messages
3,153
Reaction score
1,252
Here is the picture I came up with (Attachment).

It's like saying this;

Hovering over the link to this section (on forum.ragezone.com ~ index) and a drop down menu would appear. That's basically what I need. I've searched for it but couldn't find anything. The buttons look really ugly on my site.

Either that type of code or sub navigation code.

Basically what I'm saying here is; click on the plain HTML text then the sub navigation would appear down below in it's own content box.
 

Attachments

You must be registered for see attachments list
Custom Title Activated
Loyal Member
Joined
Apr 9, 2007
Messages
2,408
Reaction score
256
Here is the picture I came up with (Attachment).

It's like saying this;

Hovering over the link to this section (on forum.ragezone.com ~ index) and a drop down menu would appear. That's basically what I need. I've searched for it but couldn't find anything. The buttons look really ugly on my site.

Either that type of code or sub navigation code.

Basically what I'm saying here is; click on the plain HTML text then the sub navigation would appear down below in it's own content box.

Does it need to be clicking or hovering over is good as well?
 
Elite Diviner
Joined
Jan 15, 2008
Messages
417
Reaction score
7
It is quite easy if Nyaa can't help I might be able to. It's all in the css of the site you need a hover state that drops the box for the nested list display as a block and style it.
 
Custom Title Activated
Loyal Member
Joined
Apr 9, 2007
Messages
2,408
Reaction score
256
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Drop-down menu</title>
<style type="text/css" >
#sddm {
	margin:0px;
	padding:0px;
	z-index: 30;
	}

#sddm li {
	margin:0px;
	padding:0px;
	margin-right:0px;
	list-style: none;
	float:left;
	font: bold 11px arial;
}

#sddm li span {
	display: block;
	width: auto;
	padding:8px;
	background: #1287b3;
	color: #000;
	text-align: center;
	text-decoration: none;
}

#sddm li span:hover {
	background: #FFF;
}

#sddm div {	
	position:absolute;
	visibility: hidden;
	margin: 0;
	padding:10px;
	background: #1287b3;
	border: 1px solid #000;
	text-align:left;
}

#sddm div a {
	position: relative;
	display: block;
	margin: 0;
	padding: 5px 10px;
	width: auto;
	white-space: nowrap;
	text-align: center;
	text-decoration: none;
	background: #1287b3;
	color: #FFF;
	font: 12px arial;
}

#sddm div a:hover {
	background: #045371;
	color: #FFF;
}</style>
<script type="text/javascript">
//menu
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
function movepic(img_name, img_src)
   {
   document[img_name].src = img_src;
   }
</script>
</head>
<body>
<div style="background-color:#000; width:1000px; height:30px; color:#FFF;">
<ul id="sddm">
<li><span onmouseover="mopen('m1')" onmouseout="mclosetime()""mclosetime()">example 1</span>
        <div id="m1" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">
        Text here lol<br />
        more text here <br />
        </div>
        </li>
<li><span onmouseover="mopen('m2')" onmouseout="mclosetime()""mclosetime()">example 2</span>
        <div id="m2" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">
        Text here lol<br />
        more text here <br />
        </div>
        </li>
<li><span href="#" onmouseover="mopen('m3')" onmouseout="mclosetime()""mclosetime()">example 3</span>
        </li>
<li><span href="#" onmouseover="mopen('m4')" onmouseout="mclosetime()""mclosetime()">example 4</span>
        <div id="m4" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">
        Text here lol<br />
        more text here <br />
        </div>
        </li>
</ul>
</div>
</body>
</html>
This did the job...
 
Status
Not open for further replies.
Back
Top