Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > The World Wide Web > Web Graphics, Design, Digital Images » Try my new JavaScript: Customize Dropdown Menu
Closed Thread
Old 08-13-2007, 10:52 AM   #1 (permalink)
 
Newb Techie

Join Date: Aug 2007

Posts: 2

temp304 is on a distinguished road

Default Try my new JavaScript: Customize Dropdown Menu

Customize Dropdown Menu is designed to display some choices, as: languages, countries, themes,... but it's differrent from original version in browsers. This tool combine CSS and JavaScript to create a dropdown you can add image to tilte, every choice.

Let's try dropdown below and feel differences.
Tested: IE 7, Opera 9, Firefox 2, Netscape 9

URL: www.JavaScriptBank.com/../Customize_Dropdown_Menu/

Code:
<style type=text/css>
/*
	Customize Dropdown Menu 1.0
	Author: Thái Cao Phong
	Website: www.JavaScriptBank.com
	Please keep these comments above to contact author when you use this script. Thank you very much.
	Vietnamese: Xin ban hay giu lai nhung thong tin tren de nguoi khac co the lien he voi tac gia neu ban co 
su dung doan ma nay. Cam on ban rat nhieu.
*/
img
{
	vertical-align: middle;
}
.title_dropdown
{
	padding: 1px;
	background: url(dropdown_arrow.jpg) no-repeat right;
	width: 15px;
	vertical-align: middle;
	border: 1px solid silver;
	width: 180px;
	height: 17px;
	font: 12px verdana bold;
	text-align: left;
	cursor: hand;
}
.content_dropdown
{
	position: relative;
	vertical-align: middle;
	border: 1px solid black;
	width: 180px;
}
.content_dropdown a
{
	text-decoration: none;
	color: black;
}
.content_dropdown p.off
{
	margin: 0px;
	color: black;
	padding: 3px;
	padding-left: 10px;
	cursor: hand;
	text-align: left;
}
.content_dropdown p.on
{
	background-color: #000077;
	color: white;
	margin: 0px;
	padding: 3px;
	padding-left: 10px;
	cursor: hand;
	text-align: left;
}
.content_dropdown img
{
	width: 30px;
	height: 20px;
	border: none;
	margin-right: 5px;
}
</style>
<script language=javascript>
/*
		
		    xxxxxxxxxxxxxxx   xxxxxxxxxxx     xxxx
		    xxxxxxxxxxxxxxx  xxxxxxxxxxxxx    xxxx
		    xxxxxxxxxxxxxxx  xxxxxxxxxxxxx    xxxx
		         xxxxx       xxxxxxxxxxxx     xxxx
		         xxxxx       xxxxx			  xxxx
		         xxxxx		 xxxxxxxxxxxx	  xxxx
		         xxxxx		 xxxxxxxxxxxxx	  xxxxxxxxxxx			www.JavaScriptBank.com
		         xxxxx		  xxxxxxxxxxxx	  xxxxxxxxxxxxx
		         xxxxx       		 xxxxx	  xxxx     xxxx
		   xxx   xxxxx		  xxxxxxxxxxxx    xxxx     xxxx
		   xxx  xxxxxx		 xxxxxxxxxxxxx	  xxxx     xxxx
		   xxxxxxxxxx		 xxxxxxxxxxxxx	  xxxxxxxxxxxxx
		    xxxxxxxx		  xxxxxxxxxxx      xxxxxxxxxxx

	Customize Dropdown Menu 1.0
	Author: Thái Cao Phong
	Website: www.JavaScriptBank.com
	Please keep these comments above to contact author when you use this script. Thank you very much.
	Vietnamese: Xin ban hay giu lai nhung thong tin tren de nguoi khac co the lien he voi tac gia neu ban co 
su dung doan ma nay. Cam on ban rat nhieu.
*/
var ie = navigator.appName=='Microsoft Internet Explorer'?true:false;
function toggle_dropdown(id)
{
	var div = document.getElementById(id);
	if(div.style.display == 'none')
		div.style.display = 'block';
	else
		div.style.display = 'none';
}
function getObject(evt)
{
	var srcElem;
	if(ie)
	{
		srcElem = event.srcElement;
	}
	else
	{
		srcElem = evt.target;
	}
	return srcElem;
}
function go_any_page()
{
	alert('This is example');
}
function changeStyle(pTag)
{
	pTag.className = (pTag.className == 'off' ? 'on' : 'off');
}
function dropdown_on(evt)
{
	var pTag = getObject(evt);
	if(pTag.tagName == 'P' && pTag.parentNode.id == 'language_dropdown')
		changeStyle(pTag);
}
function dropdown_off(evt)
{
	var pTag = getObject(evt);
	if(pTag.tagName == 'P' && pTag.parentNode.id == 'language_dropdown')
		changeStyle(pTag);
}
function click(evt)
{
	var pTag = getObject(evt);
	if(!document.getElementById('language_dropdown'))
		return;
	if(pTag.tagName == 'DIV' && pTag.className == 'title_dropdown')
		toggle_dropdown('language_dropdown');
	else if(document.getElementById('language_dropdown').style.display == 'block')
		toggle_dropdown('language_dropdown');
}
document.onmouseover = dropdown_on;
document.onmouseout = dropdown_off;
document.onclick = click;
</script>
<div class=title_dropdown><img class=imgclass src="flag.png">Choose your country</div>
	<div id=language_dropdown style='display: none; z-index: -100;' class=content_dropdown>
		<p class=off onClick="go_any_page();"><img src='brazil.gif'>Brazil</p>
		<p class=off onClick="go_any_page();"><img src='japan.gif'>Japan</p>
		<p class=off onClick="go_any_page();"><img src='usa.gif'>USA</p>
		<p class=off onClick="go_any_page();"><img src='vietnam.gif'>Vietnam</p>
	</div>

temp304 is offline  
Old 08-13-2007, 05:24 PM   #2 (permalink)
mssssee2's Avatar
 
Graphic Designer

Join Date: Apr 2007

Location: Thessaloniki, Greece

Posts: 507

mssssee2 is on a distinguished road

Send a message via MSN to mssssee2 Send a message via Yahoo to mssssee2
Default Re: Try my new JavaScript: Customize Dropdown Menu

It pops me up an alert() with the message "This is an example", no matter what I choose from the dropdown menu.
__________________
Mike from Greece, 16

mssssee2 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any programming experts (Javascript?) I need a job done, will pay Quintox Programming Discussions 2 08-01-2007 05:29 PM
Start menu doesn't "remember" in Vista kfc469 Windows Operating Systems and Software 9 06-11-2007 11:57 PM
trying to help my dad.. now i need help spacetiger HijackThis Logs (finished) 17 06-03-2007 02:44 PM
quick javascript help joe33 Programming Discussions 1 05-15-2007 04:29 PM
JavaScript Botnet Code Leaked To Internet Osiris Virus - Spyware Protection / Detection 0 04-02-2007 09:05 PM