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:
<dt><a 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
******************************************************