Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Expandable menu - how to trace and leave opened last clicked element?
Old 08-24-2010, 01:45 PM Expandable menu - how to trace and leave opened last clicked element?
Junior Talker

Posts: 1
Name: Kacper
Trades: 0
Hi folks

Currently I am developing a simple CMS in PHP and MySQL. I almost finished it but got stuck with displaying menu.

Idea is basic - for displaying menus I use PHP and generate it with <ul> & <li> items. If I want a sub-menu I open another <ul> within <li> tags. To enable expanding (opening it) and collapsing it, I use a simple JS function:

Code:
function showHide(msg_id)
{
	var element = document.getElementById(msg_id);
	element.style.display = element.style.display=='block' ? 'none' : 'block';
}
But every time I click a link wich is not "a folder item" (it does not containt any sub-menu) and page reloads to display an article, all submenus collapse. I would like to have expanded the sub-menu which contained a link that was clicked. How to achieve it?

I will appreciate any help with JS functions or links to tutorials...

PS. I am totally new to JS. I tried to google it, but since english is not my native language I probably use wrong keywords...
fakirinho is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-24-2010, 01:57 PM Re: Expandable menu - how to trace and leave opened last clicked element?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Save the ID to a cookie
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Expandable menu - how to trace and leave opened last clicked element?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09502 seconds with 12 queries