473,806 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2 buttons acting at once - css and php - maybe javascript?

1 New Member
I am pretty much stuck and dont know which direction to procede in figuring this out. My desired end result is to have top_home button and bottom_home button to be on opposite areas of the page, but when I rollover top_home or bottom_home the other reacts with thier own roll over state as though they are just one button. (rollover 1 and both activate the rollover state) Of course I cant have just one large button layingg over the entire page because all of the space in between would be dead then and useless. Also, the buttons are different in that

top_home has 2 states [current state1 and roll over state]
bottom_home has 3 states [current state1, current state 2 and roll over state]


.css file:
Expand|Select|Wrap|Line Numbers
  1. /* Bottom Nav */
  2. #topNav {position:absolute; top:0; left:30px;}
  3. #topNav li {float:left; margin-right:10px;}
  4. #topNav li.home a {background:url(../images/top_home.png) no-repeat; width:116px; height:22px;}
  5. #topNav li a:hover {background-position:bottom;}
  6. #topNav li a.current, #topNav li a.current:hover {background-position:bottom;}
  7.  
  8. /* Bottom Nav */
  9. #bottomNav {position:absolute; bottom:34px; right:0;}
  10. #bottomNav li {float:left; margin-left:5px;}
  11. #bottomNav li.home a {background:url(../images/bottom_home.png) no-repeat; width:144px; height:27px;}
  12. #bottomNav li a:hover {background-position: 0 -27px}
  13. #bottomNav li a.current, #bottomNav li a.current:hover {background-position:bottom;}
  14.  
  15.  
If its not obvious.
The button image is made up of the multiple states in the one image. 2 button states one on top of the another in the case of top_home and 3 states in the same image in the case of bottom_home. The .css tells the button, depending upon which page is being displayed to move the image up or down to reviel that state.

basically image looks like this:

top_home:

HOME
HOME


bottom_home:

HOME
HOME
HOME


html/PHP code
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. #debug function
  3. function debug ($array,$die = false) {
  4.     echo "<pre>";
  5.     print_r($array);
  6.     echo "</pre>";
  7.     if($die) {
  8.         die();
  9.     }
  10. }
  11.  
  12. #debug($_SERVER);
  13. #figure out file name
  14. $url = $_SERVER['SCRIPT_NAME'];
  15.  
  16. if(preg_match('/clients/',$url)) {
  17.     $clients = true;
  18. }
  19. elseif(preg_match('/contact/',$url)) {
  20.     $contact = true;
  21. }
  22. elseif(preg_match('/portfolio/',$url)) {
  23.     $portfolio = true;
  24. }
  25. elseif(preg_match('/index/',$url)) {
  26.     $home = true;
  27. }
  28. ?>
  29.  
  30. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  31. <html xmlns="http://www.w3.org/1999/xhtml">
  32.  
  33. <head>
  34. <meta name="Copyright" content="" />
  35. <meta name="Author" content="" />
  36. <meta name="Description" content="" />
  37. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
  38. <title>TITLE <?php echo isset($title) ? $title : '';?></title>
  39. <link href="/includes/style.css" rel="stylesheet" type="text/css"/>
  40. <script language="javascript">AC_FL_RunContent = 0;</script>
  41. <script src="AC_RunActiveContent.js" language="javascript"></script>
  42. </head>
  43.  
  44. <body>
  45.  
  46. <div id="topNav">
  47.         <ul>
  48.             <li class="home"><a href="/index.php" <?php if(!empty($home)) echo 'class="current"';?>>Home</a></li>
  49.         </ul>
  50.     </div><!-- topNav -->
  51.  
  52.     <div id="bottomNav">
  53.         <ul>
  54.             <li class="home"><a href="/index.php" <?php if(!empty($home)) echo 'class="current"';?>>Home</a></li>
  55.         </ul>
  56.     </div><!-- bottomNav -->
  57.  


Hope this is clear. Thanks for any help.
Feb 24 '08 #1
1 1277
mrking
28 New Member
You need to use something more like this:

Expand|Select|Wrap|Line Numbers
  1. .companyrollover a{
  2.     display: block;
  3.     width: 95px;
  4.     height: 20px;
  5.     background: url(image-name.jpg) no-repeat;
  6.     text-decoration: none;
  7.     float: left;
  8.          }
  9.  
  10. .companyrollover a:hover {
  11.     background-position: -95px 0;
  12.            }
  13.  
  14. .companyrollover a:current{
  15.     background-position: -190px 0;
  16.     }
  17.  
  18.  
Mar 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
8488
by: bbxrider | last post by:
i have 2 radio buttons 1 for yes and 1 for no, it is mandatory for one to be checked, and am purposely leaving both blank on the page when i tested for .value, when neither was checked, an alert message comes back with literally 'undetermined', and i get the message 2x, once for each button alert("empty prevVolunteer is " + e.value); i.e, the text in the message box is "empty prevVolunteer undetermined" i haven't found anything...
3
1677
by: Jason | last post by:
I have two applications that I wrote that use asp and javascript source files. Recently both of these applications starting acting strange on my test box. Image icons will randomly stop showing up and any javascript that I use a src file with <script language="javascript" src="mytest.js"></script> ) returns random errors. Javascript on the page itself works fine. If I click f5 multiple times I will get different results. I am...
7
1777
by: Jairo Nieto | last post by:
Hi, I've had this extremely weird problem for a week or so, and havent been able to solve it. My solution works fine on the production server. Once I deploy it, all buttons stop posting back (they still validate though). Other page controls do postback. On some clients, the application buttons do post back once, and from there on, the buttons stop working forever. I have a couple of theories, but correcting them has no effect at all....
6
2053
by: pmud | last post by:
Hi, I have created a very simple ASP.NET application which has a couple of ImageButtons which go to different SQL reports on clicking them. I have used Response.Redirect to send the user to the SQL reports. Now after viewing the report when I hit the Baxk Button on my browser. and then I click the image buttons, nothing happens. Any ideas why this is happening?
1
2748
by: Bill_W_Stephens | last post by:
I have a complicated page with several submit buttons. I don't want to create multiple forms because much of the input is shared and the code is getting very ugly. However I would like to determine which values will be submited. Here is a simplified example that may better illustrate my question. Or maybe there is a better approach... <SCRIPT language="JavaScript">
22
7989
by: Saul | last post by:
I have a set of radio buttons that are created dynamically, after rendered I try loop thru this set by getting the length of the set, but I keep getting an error stating the element is undefined. I am using getElelementsByName since these are radio buttons, but it seems that the dynamic element is not seen!!! This is my code... please let me know if there is anything that I am doing wrong! - thanks ---- ....
6
2217
by: shror | last post by:
i want to add a midi file to my pages and i want to put two radio buttons so that on is on and the other is off so that the users can start or stop the file playing by choosing one of the radio buttons, but the problem is that i dont know how to do it. does any body know how this could be done Thanks in advance for your help shror www.s7els7.com
7
4876
by: moksha | last post by:
Hi, I am new to javascript and i am facing a problem in coding. plz help me out. I am using javascript for dynamically creating a table row which contains text boxes and radio buttons and check box. I am adding two radio buttons once for a row.Now my problem is the radio buttons in all the rows that added dynamically are behaving as same group i.e when i am selecting a radio button in second row,radio button in first row...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.