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
Old 08-11-2007, 11:14 AM [Resolved] Hide/Show Table
Experienced Talker

Posts: 33
Trades: 0
Greetings,

On the left side of my website I have a navigation menu built from a table. I would like to give visitors the option of hiding this table.

I would like the table to behave like this:

1.) When the website is visited, the table is visible.
2.) Somewhere near the table there is an option to hide the table. This could be a small "<" image, for example.
3.) When that option is clicked, the table is "pushed" to the far left, off the screen. This is the hiding concept.
4.) After the table is hidden, there would exist an option to display the table again. This could be a small ">" image, for example.

What is the most correct way to design this feature? Compatibility across multiple web browsers is very important here. I know some CSS and have only seen JavaScript but would appreciate code snippets and technical explanations.

Thank you for your time,

Nick

Last edited by nick1; 08-15-2007 at 09:37 AM..
nick1 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-11-2007, 12:12 PM Re: Hide/Show Table
JamieLewis's Avatar
Pretty Much a Big Deal...

Latest Blog Post:
Gooie
Posts: 385
Name: Jamie Lewis
Location: UK
Trades: 0
Quote:
What is the most correct way to design this feature?
  • First design navigation in a list format. Thiis is purely for accessibility reasons.
  • Secondly read up on DOM and implementation.
  • When the javascript is run add the button element that will do the hiding
  • Add an onclick event to the button.
  • When the button is pushed run a function that affects the style of the navigation list.
  • Design the function so that it sets a variable so you know whether to hide or show the list when the button is clicked.
  • Sit back and enjoy your accessible site.
Jamie
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
JamieLewis is offline
Reply With Quote
View Public Profile Visit JamieLewis's homepage!
 
Old 08-15-2007, 09:33 AM Re: Hide/Show Table
Experienced Talker

Posts: 33
Trades: 0
Thank you for your help. I decided to go with this solution:

Code:
        <script type="text/javascript">

            //Purpose: Hides or shows the menu div.

            //<![CDATA[
                
                var hide = false;

                function HideShowMenu() {

                    hide = !hide;

                    if(hide) {

                        document.getElementById('menu').style.display = 'none';

                    } else {

                        document.getElementById('menu').style.display = 'block';

                    }

                }

            //]]>

        </script>
Along with your help, I also found Learning JavaScript by Shelley Powers (O'Reilly) page 263 very helpful.

Thanks,

Nick
nick1 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Hide/Show Table
 

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.17549 seconds with 12 queries