[WSG] question about CSS menu (javascript)
Hello. I'm doing a drop-down menu (a bit differently than usual), and there is only one thing I can't seem to accomplish. The menu is at http://www.drzeus.net/lab/verticalmenu.html The user should be able to click on a tab to expand it, which it currently does, but clicking it again should contract the menu (that's the part I need help with, please). I realize that a javascript question isn't exactly about standards, but since the menu itself is XHTML/CSS, and hopefully others will find the menu useful. Thank you. -- ~john _ Dr. Zeus Web Development http://www.DrZeus.net content without clutter ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
RE: [WSG] question about CSS menu (javascript)
Try this: window.onload=show; function show(id) { var d = document.getElementById(id); for (var i = 1; i=10; i++) { if (document.getElementById('submenu'+i)) {document.getElementById('submenu'+i).style.display='none';} } if (d) {d.style.display='block';} } function showhide(id) { if (document.getElementById(id).style.display==none){ document.getElementById(id).style.display=block } else{ document.getElementById(id).style.display=none } } in HTML: dta href=#Home page/a/dt dt onclick=javascript:showhide('submenu1');Technology/dt Though I'm sure the JavaScript could be cut further. Regards Mike 2k:)2 Mike Foskett Web Standards, Accessibility Testing Consultant Multimedia Publishing and Production British Educational Communications and Technology Agency (Becta) Milburn Hill Road, Science Park, Coventry CV4 7JJ Email: [EMAIL PROTECTED] Tel: 02476 416994 Ext 3342 [Tuesday - Thursday] Fax: 02476 411410 www.becta.org.uk -Original Message- From: john [mailto:[EMAIL PROTECTED] Sent: 16 March 2005 10:09 To: web standards group Subject: [WSG] question about CSS menu (javascript) Hello. I'm doing a drop-down menu (a bit differently than usual), and there is only one thing I can't seem to accomplish. The menu is at http://www.drzeus.net/lab/verticalmenu.html The user should be able to click on a tab to expand it, which it currently does, but clicking it again should contract the menu (that's the part I need help with, please). I realize that a javascript question isn't exactly about standards, but since the menu itself is XHTML/CSS, and hopefully others will find the menu useful. Thank you. -- ~john _ Dr. Zeus Web Development http://www.DrZeus.net content without clutter ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help ** ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ** ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] question about CSS menu (javascript)
Hi John, I use a similar drop-down menu on my El BombĂn site http://elbombin.stuarthomfray.co.uk/ (javascript: http://elbombin.stuarthomfray.co.uk/menutoggle.js) - as far as I can tell it works on pretty much every browser (although Opera 7 seems to require an inline style for the 'display:none' declaration), and it stores the value in a cookie. Mike Foskett's version beat me to it, though, AND it's structured to allow multiple menu drop-downs, so it will probably suit your needs better! cheers, Stuart john wrote: Hello. I'm doing a drop-down menu (a bit differently than usual), and there is only one thing I can't seem to accomplish. The menu is at http://www.drzeus.net/lab/verticalmenu.html The user should be able to click on a tab to expand it, which it currently does, but clicking it again should contract the menu (that's the part I need help with, please). I realize that a javascript question isn't exactly about standards, but since the menu itself is XHTML/CSS, and hopefully others will find the menu useful. Thank you. ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **