Showing or hiding content with Javascript..

Discussion in 'JavaScript' started by toughguy, Mar 25, 2007.

  1. #1
    Hi Friends,
    Thanks a lot for looking at my post..

    I want to implement the following using javascript.. But iam not sure how it can be done.

    I want to load a page with few different types of info. say details of city, hotels in the city, places to visit, flight timings, etc. What i want to do is: When the page loads only the content related to city is to be displayed and the remaining info should be hidden. There will be links for city info , hotel info, places info, fligth timing info. When user clicks on say places info i want to show the content related to places info and hide info related to city.

    Can this be done in an easy manner??

    If so can somebuddy give me some clue or direct me to any source that can help me..

    Thanks a lot..

    Eagerly waiting for ur replies..

    I found this following link: http://willmaster.com/blog/css/show-hide_div-layer.html
    Can some buddy direct me to any other resource..

    Regards,
     
    toughguy, Mar 25, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    
    <html>
    <head>
    <title>Show hide shit</title>
    <script language="javascript">
    	function swapContent( oB )
    	{
    		if( document.getElementById( oB ).style.display == "none" )
    			document.getElementById( oB ).style.display = "";
    		else
    			document.getElementById( oB ).style.display = "none"; 	
    	}
    </script>
    </head>
    
    <body>
    <a href="javascript:swapContent( 'objectTest');swapContent( 'objectTest2');">Click Me</a>
    <div id="objectTest">
    hello my name is joe
    </div>
    <div id="objectTest2" style="display:none;">
    I live in the uk
    </div>
    </body>
    </html>
    
    HTML:
    I changed it a bit, that's how I would do that .....
     
    krakjoe, Mar 25, 2007 IP
    Manju99 and toughguy like this.
  3. toughguy

    toughguy Well-Known Member

    Messages:
    846
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    118
    #3
    Hi Joe,
    Thanks a lot.. will give it a try..

    Regards,
     
    toughguy, Mar 25, 2007 IP