473,797 Members | 3,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Some help with dropdown menus

3 New Member
Hi, I have just joined the forum and I need help with Javascrip dropdown menus. I have written a function which should change the background image of a button when it is clicked:

function change(el)
{

if (el.style.backg round='url(arro w-up-title2.jpg)'){
el.style.backgr ound='url(arrow-down-title2.jpg)'
}

if (el.style.backg round='url(arro w-down-title2.jpg)'){
el.style.backgr ound='url(arrow-up-title2.jpg)'
}


}


The problem is the background only changes once. When I click on the main menu the background is originally arrow-down-title2.jpg and this changes to arrow-up-title2.jpg but when I click the menu again it does not change back to arrow-down-title2.jpg.

Does anyone have an idea why?

This is how I pass my parameter:

<div id="menu" onclick="change (this);SwitchMe nu('sub1')">Men u</div>
Mar 4 '08 #1
3 1198
debasisdas
8,127 Recognized Expert Expert
Question moved to Javascript forum.
Mar 4 '08 #2
hsriat
1,654 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. var bg = 0;
  2. function change(el) {
  3.     el.style.background = bg ? 'url(arrow-down-title2.jpg)' : 'url(arrow-up-title2.jpg)';
  4.     bg = !bg;
  5. }
Mar 4 '08 #3
angelinahmaleka
3 New Member
Expand|Select|Wrap|Line Numbers
  1. var bg = 0;
  2. function change(el) {
  3.     el.style.background = bg ? 'url(arrow-down-title2.jpg)' : 'url(arrow-up-title2.jpg)';
  4.     bg = !bg;
  5. }
Wow, it works. Thank you so much !!!!!!!!!!!!!!! !!!!!!!!!!!!
Mar 4 '08 #4

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

Similar topics

19
2864
by: chart43 | last post by:
I have question about the technique for css dropdown menus described in http://www.alistapart.com/articles/horizdropdowns/. Based on an html list, it has a few items in a 1st order list and further 2nd order lists that appear to the right when hovering over items in the 1st order. Anyone figured how to modify to go to n order greater than 2? Bit tricky I found. I could get the other orders but they all appeared when hovering over the 1st...
18
2195
by: sandy | last post by:
This sounds like a frequently asked question, but I didn't find the answer in any faq I've looked at. I have a question about the wisdom of using (javascript generated) dropdown menus. Question: Does google interpret javascript? Or, in other words, are client-side-javascript-generated links invisible to search engines?
1
1121
by: Patrick Cambre | last post by:
Hello all, I just registered with the forum. Glad to be with you all! During the last few days I have been improving my website with dropdown menus. I found this one at... http://www.finitechess.com/cyberspace/html/set19.htm It works fine on my webpage. But if I try to put more then one script on the same webpage, I get into trouble.
6
16228
by: nishac | last post by:
Can anyone suggest me how to make my drop down menu work in IE7 too.Its working in other browsers.On mouse over the submenus should be displayed.Am attaching my css code hereby.Anyone please check and give a positive reply. menu HOme products support..... | | submenus p1 A p2 B.. p3... /*================= STYLES FOR THE PRIMARY NAV...
4
2348
torquehero
by: torquehero | last post by:
Hi all :) I have created a horizontal navbar using Xara Menumaker. The Menu items have several dropdown menus. Its a javascript. When the mouse cursor is moved over any menu item, a dropdown list/menu appears. When the page is opened in the browser (as it appears by default), the dropdown menu positions are correctly displayed. But when I scroll the page and then move the mouse over any menu item of the navbar, the dropdown menu is not...
4
2126
by: bloukopkoggelmander | last post by:
Hello all A strange problem here. We have an Access 2000 database in use. I upgraded one user to Office 2003 SP3. When he now open this database, all dropdown boxes are displaying blank menus. When I open the same database in Office 2002, the dropdown boxes have populated menus. Now I have converted the database to 2002 format and it still works fine when opening in 2002, but still have the same problem when opening in 2003. Has anyone...
19
3695
by: Jim | last post by:
Hi, I have two questions/problems pertaining to CSS horizontal dropdown menus and am hoping that someone here can help me out. (1) I'm having a problem centering the menu. I picked up the code for this from a tutorial but that menu was flush-left justified. Not what I want. Subsequent searches on google on how to center yielded a
1
5060
by: ibeehbk | last post by:
HI. I have a dropdown menu named arrivalcity (options are Rome, Naples, Palermo, and CAtania). I also have 4 other dropdown menus which have departure dates for those cities. Basically I want those 4 dropdown menus disabled by default. Then based on which arrivalcity option they choose only one of those 4 dropdown menus gets enabled so they can select the departure date from the appropriate menu. I know this can get accomplished in...
1
2664
by: sydd | last post by:
Hi, I was wondering if it's possible to create a dynamic dropdown menu from this code. if($rs->getNumRows() > 0){ $intProjectCount = 1; $htmlOut ="<table width='100%' border='0' align='center' cellpadding='1' cellspacing='0'>"; foreach($rs->fetch() as $prs){ $htmlOut .="<tr><td class=\"projectkiri\" ><a href=\"/index.php?page=PROJECTS&id=".$prs."\">".$prs."</a></td></tr>";
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9537
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
10469
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
10023
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
9066
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...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.