Current location: Hot Scripts Forums » Programming Languages » PHP » onmouseover


onmouseover

Reply
  #1 (permalink)  
Old 09-24-08, 02:01 AM
Miben Miben is offline
Wannabe Coder
 
Join Date: Sep 2008
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
onmouseover

HTML Code:
<ul>
		<li><a href="#">Home</a></li>
		<li><a href="#" rel="dropmenu1" onmouseover="setVisibility('dropmenu1', 'inline');" onmouseout="setVisibility('dropmenu1','none');">Setting</a></li>
		<li><a href="#" >Profile</a></li>
		</ul>
		</div>

		<!--1st drop down menu --> 
		<div id="dropmenu1" class="dropmenudiv">
		<a href="#">Marks Setting</a>
		<a href="#">Course Setting</a>
		<a href="#">Subject Setting</a>
		</div>
The above code not works..
Any idea to solve the onmouseover problem?

Last edited by Nico; 09-24-08 at 02:26 AM. Reason: Wrappers.
Reply With Quote
  #2 (permalink)  
Old 09-24-08, 02:26 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Where's your setVisibility() function?
Reply With Quote
  #3 (permalink)  
Old 09-24-08, 02:40 AM
Miben Miben is offline
Wannabe Coder
 
Join Date: Sep 2008
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Below is my setVisibility() function:

<script language="Javascript">
function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}
</script>
Reply With Quote
  #4 (permalink)  
Old 09-24-08, 06:34 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
It seems to work fine when I do it this way.
HTML Code:
<script language="Javascript">
function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}
</script>
<style>
.dropmenudiv
{
 display:none;
 }
</style>
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#" rel="dropmenu1" onmouseover="setVisibility('dropmenu1', 'inline');" onmouseout="setVisibility('dropmenu1','none');">Setting</a></li>
        <li><a href="#" >Profile</a></li>
        </ul>
        </div>

        <!--1st drop down menu -->
        <div id="dropmenu1" class="dropmenudiv">
        <a href="#">Marks Setting</a>
        <a href="#">Course Setting</a>
        <a href="#">Subject Setting</a>
        </div>
Maybe you have something else wrong in your code.
__________________
Jerry Broughton
Reply With Quote
  #5 (permalink)  
Old 09-24-08, 09:01 PM
Miben Miben is offline
Wannabe Coder
 
Join Date: Sep 2008
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for help
Reply With Quote
  #6 (permalink)  
Old 09-24-08, 11:34 PM
Miben Miben is offline
Wannabe Coder
 
Join Date: Sep 2008
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
HTML Code:
<html>
<head>
<title>Dynamic Drive DHTML Scripts- Chrome CSS Drop Down Menu</title>

<script language="JavaScript">
function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}
</script>	

<style type="text/css">
.chromestyle{
width: 99%;
font-weight: bold;
}

.chromestyle:after{ /*Add margin between menu and rest of content in Firefox*/
content: "."; 
display: block; 
height: 0; 
clear: both; 
visibility: hidden;
}

.chromestyle ul{
border: 1px solid #BBB;
width: 100%;
background: url(chromebg.gif) center center repeat-x; /*THEME CHANGE HERE*/
padding: 4px 0;
margin: 0;
text-align: left; /*set value to "left", "center", or "right"*/
}

.chromestyle ul li{
display: inline;
}

.chromestyle ul li a{
color: #494949;
padding: 4px 7px;
margin: 0;
text-decoration: none;
border-right: 1px solid #DADADA;

}

.chromestyle ul li a:hover, .chromestyle ul li a.selected{ /*script dynamically adds a class of "selected" to the current active menu item*/
background: url(chromebg-over.gif) center center repeat-x; /*THEME CHANGE HERE*/

}

/* ######### Style for Drop Down Menu ######### */

dropmenudiv{
position:absolute;
top: 0px;
border: 1px solid #BBB; /*THEME CHANGE HERE*/
border-bottom-width: 0;
font:normal 12px Verdana;
line-height:18px;
z-index:100;
background-color: white;
width: 200px;
visibility: hidden;
}


.dropmenudiv a{
width: auto; /*Set the dropdown length*/
display: block;
text-indent: 3px;
border-bottom: 1px solid #BBB; /*THEME CHANGE HERE*/ 
padding: 2px 0;
text-decoration: none;
font-weight: bold;
color: black;

}

.dropmenudiv a:hover{ /*THEME CHANGE HERE*/
background-color: #F0F0F0;

}

</style>	
</head>
<body>
	<div>
		<div class="chromestyle" id="chromemenu">
		<ul>
        <li><a href="#">Home</a></li>
        <li><a href="#" rel="dropmenu1" onMouseOver="setVisibility('dropmenu1', 'inline');" onMouseOut="setVisibility('dropmenu1','none');">Setting <img src="images/down.gif" border="0" /></a></li>
        <li><a href="#" onMouseOver="setVisibility('dropmenu2', 'inline');" onMouseOut="setVisibility('dropmenu2','none');">Profile <img src="images/down.gif" border="0" /></a></li>
        </ul>
        </div>

        <!--1st drop down menu -->
        <div id="dropmenu1" class="dropmenudiv">
        <a href="#">Marks Setting</a>
        <a href="#">Course Setting</a>
        <a href="#">Subject Setting</a>
        </div>
        
        <div id="dropmenu2" class="dropmenudiv">
        <a href="#">Add Profile</a>
        <a href="#">View Profile</a>
        </div>		
        
	</div>
</body>
</html>

This is the sample code that I done. It's works.
But, when I run the code, by default the drop down menu is displayed.
The drop down menu suppose be displayed when I mouse over it.

What should I do to overcome it?

Last edited by Nico; 09-25-08 at 02:13 AM. Reason: Wrappers.
Reply With Quote
  #7 (permalink)  
Old 09-25-08, 02:14 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Miben, please use [html] [/html] wrappers when posting HTML code.

More info here: http://www.programmingtalk.com/misc.php?do=bbcode#html
Reply With Quote
  #8 (permalink)  
Old 09-25-08, 11:06 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Try it like this:

PHP Code:

<html>
<
head>
<
title>Dynamic Drive DHTML ScriptsChrome CSS Drop Down Menu</title>
<
script language="JavaScript">
function 
setVisibility(id1visibility1id2visibility2) {
document.getElementById(id1).style.display visibility1;
document.getElementById(id2).style.display visibility2;
}
</script>    
<style type="text/css">
.chromestyle{
width: 99%;
font-weight: bold;
}
.chromestyle ul{
border: 1px solid #BBB;
background: url(chromebg.gif) center center repeat-x; /*THEME CHANGE HERE*/
padding: 4px 0;
margin: 0;
text-align: left; /*set value to "left", "center", or "right"*/
}
.chromestyle ul li{
display: inline;
}
.chromestyle ul li a{
color: #494949;
padding: 4px 7px;
margin: 0;
text-decoration: none;
border-right: 1px solid #DADADA;
}
.chromestyle ul li a:hover, .chromestyle ul li a.selected{ /*script dynamically adds a class of "selected" to the current active menu item*/
background: url(chromebg-over.gif) center center repeat-x; /*THEME CHANGE HERE*/
}
/* ######### Style for Drop Down Menu ######### */
.dropmenudiv{
position:absolute;
border: 1px solid #BBB; /*THEME CHANGE HERE*/
border-top: 0px;
border-bottom: 0px;
font:normal 12px Verdana;
line-height:18px;
background-color: #FFF;
width: 200px;
display:none;
}
.dropmenudiv a{
width: 198px; /*Set the dropdown length*/
display: block;
text-indent: 3px;
border-bottom: 1px solid #BBB; /*THEME CHANGE HERE*/
padding: 2px 0;
text-decoration: none;
font-weight: bold;
color: #000;
}
.dropmenudiv a:hover{ /*THEME CHANGE HERE*/
background-color: #F0F0F0;
}
</style>    
</head>
<body>
 <div>
  <div class="chromestyle" id="chromemenu">
    <ul>
    <li><a href="#" onmouseover="setVisibility('dropmenu1', 'none', 'dropmenu2', 'none');">Home</a></li>
    <li><a href="#" rel="dropmenu1" onmouseover="setVisibility('dropmenu1', 'inline', 'dropmenu2', 'none');">Setting <img src="images/down.gif" border="0" /></a></li>
    <li><a href="#" onmouseover="setVisibility('dropmenu1', 'none', 'dropmenu2', 'inline');">Profile <img src="images/down.gif" border="0" /></a></li>
   </ul>
  </div>
  <!--1st drop down menu -->
  <div id="dropmenu1" class="dropmenudiv" onmouseout="setVisibility('dropmenu1', 'none', 'dropmenu2', 'none');">
   <a href="#" onmouseover="setVisibility('dropmenu1', 'inline', 'dropmenu2', 'none');">Marks Setting</a>
   <a href="#" onmouseover="setVisibility('dropmenu1', 'inline', 'dropmenu2', 'none');">Course Setting</a>
   <a href="#" onmouseover="setVisibility('dropmenu1', 'inline', 'dropmenu2', 'none');">Subject Setting</a>
  </div>
  <div id="dropmenu2" class="dropmenudiv" onmouseout="setVisibility('dropmenu1', 'none', 'dropmenu2', 'none');">
   <a href="#" onmouseover="setVisibility('dropmenu1', 'none', 'dropmenu2', 'inline');">Add Profile</a>
   <a href="#" onmouseover="setVisibility('dropmenu1', 'none', 'dropmenu2', 'inline');">View Profile</a>
  </div>        
 </div>
</body>
</html> 
__________________
Jerry Broughton
Reply With Quote
  #9 (permalink)  
Old 09-25-08, 11:55 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
I forgot to add the z-index back in.
So here is the code with the z-index added.

PHP Code:

<html>
<
head>
<
title>Dynamic Drive DHTML ScriptsChrome CSS Drop Down Menu</title>
<
script language="JavaScript">
function 
setVisibility(id1visibility1id2visibility2) {
document.getElementById(id1).style.display visibility1;
document.getElementById(id2).style.display visibility2;
}
</script>    
<style type="text/css">
.chromestyle{
width: 99%;
font-weight: bold;
}
.chromestyle ul{
border: 1px solid #BBB;
background: url(chromebg.gif) center center repeat-x; /*THEME CHANGE HERE*/
padding: 4px 0;
margin: 0;
text-align: left; /*set value to "left", "center", or "right"*/
}
.chromestyle ul li{
display: inline;
}
.chromestyle ul li a{
color: #494949;
padding: 4px 7px;
margin: 0;
text-decoration: none;
border-right: 1px solid #DADADA;
}
.chromestyle ul li a:hover, .chromestyle ul li a.selected{ /*script dynamically adds a class of "selected" to the current active menu item*/
background: url(chromebg-over.gif) center center repeat-x; /*THEME CHANGE HERE*/
}
/* ######### Style for Drop Down Menu ######### */
.dropmenudiv{
position:absolute;
border: 1px solid #BBB; /*THEME CHANGE HERE*/
border-top: 0px;
border-bottom: 0px;
font:normal 12px Verdana;
line-height:18px;
background-color: #FFF;
width: 200px;
display:none;
z-index:100;
}
.dropmenudiv a{
width: 198px; /*Set the dropdown length*/
display: block;
text-indent: 3px;
border-bottom: 1px solid #BBB; /*THEME CHANGE HERE*/
padding: 2px 0;
text-decoration: none;
font-weight: bold;
color: #000;
}
.dropmenudiv a:hover{ /*THEME CHANGE HERE*/
background-color: #F0F0F0;
}
</style>    
</head>
<body>
 <div>
  <div class="chromestyle" id="chromemenu">
    <ul>
    <li><a href="#" onmouseover="setVisibility('dropmenu1', 'none', 'dropmenu2', 'none');">Home</a></li>
    <li><a href="#" rel="dropmenu1" onmouseover="setVisibility('dropmenu1', 'inline', 'dropmenu2', 'none');">Setting <img src="images/down.gif" border="0" /></a></li>
    <li><a href="#" onmouseover="setVisibility('dropmenu1', 'none', 'dropmenu2', 'inline');">Profile <img src="images/down.gif" border="0" /></a></li>
   </ul>
  </div>
  <!--1st drop down menu -->
  <div id="dropmenu1" class="dropmenudiv" onmouseout="setVisibility('dropmenu1', 'none', 'dropmenu2', 'none');">
   <a href="#" onmouseover="setVisibility('dropmenu1', 'inline', 'dropmenu2', 'none');">Marks Setting</a>
   <a href="#" onmouseover="setVisibility('dropmenu1', 'inline', 'dropmenu2', 'none');">Course Setting</a>
   <a href="#" onmouseover="setVisibility('dropmenu1', 'inline', 'dropmenu2', 'none');">Subject Setting</a>
  </div>
  <div id="dropmenu2" class="dropmenudiv" onmouseout="setVisibility('dropmenu1', 'none', 'dropmenu2', 'none');">
   <a href="#" onmouseover="setVisibility('dropmenu1', 'none', 'dropmenu2', 'inline');">Add Profile</a>
   <a href="#" onmouseover="setVisibility('dropmenu1', 'none', 'dropmenu2', 'inline');">View Profile</a>
  </div>        
 </div>
</body>
</html> 
__________________
Jerry Broughton
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
onMouseOver / Out problem jonnekke JavaScript 1 08-05-08 08:31 AM
onmouseover effect Ares JavaScript 22 05-20-06 12:51 PM
onMouseOver works on my computer, but not online naomiomio JavaScript 4 03-04-06 02:02 PM
Image resize onmouseover !!! CnB HTML/XHTML/XML 2 10-16-05 04:03 PM
I need a script for onMouseOver, image zooming + fading AgentRed Script Requests 0 09-06-04 06:21 PM


All times are GMT -5. The time now is 08:20 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.