Results 1 to 5 of 5

Thread: Content switcher

  1. #1
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default Content switcher

    Hi guys, I'm looking for a way of switching content on click, I know this should be pretty simple but the ones on here are all a bit too much for what I'm looking for, and trying to strip them down to produce what I want isn't working the way I want it to, here is a screenshot of the page I have at the moment:

    http://www.bombthehills.com/test/ukmap.png

    Where it says "info gallery calendar", I want to be able to dynamically switch the content without leaving the page, I think you know what I mean, should be pretty simple code,

    Thanks for any help given,

    Jack

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Where is the content coming from? Is it all in the markup (so you're just showing/hiding divs)? Or are you bringing it in from an external source (AJAX)?

    Are you up to using jQuery?

  3. #3
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Well, what happens at the moment is there's an image map which shows when centres are clicked on, but then I also want to be able to show / hide content on divs that are already shown / hidden.

    I could use jQuery maybe, although I'm not very good at stuff like that, to help understand more I've uploaded a test page to the site:

    http://www.bombthehills.com/test/ridingspots-uk.html

    The centre that is nearly done is "Ivyleaf", it's in the south west, second from the left. Hope this helps, I mean jQuery is ok if needs be, but I'd really prefer to just use something much simpler, like making a div display:block on click, and everything else hidden.

    Anyways, tell me the next step,

    Thanks very much,

    Jack.

  4. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    It doesn't really get simpler than jQuery. You could use regular javascript as well. It'll be more tedious code writing. But, it'll work.

  5. The Following User Says Thank You to Medyman For This Useful Post:

    Schmoopy (11-19-2008)

  6. #5
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Sweet, i've got it working now using that page you linked to, but I want a way to condense it a bit, at the moment I have this:

    Code:
    <script>
        function toggle_visibility(id) {
           var content = document.getElementById(id);
           if(content.style.display == 'block'){
              content.style.display = 'none';
    		  }
    		  else
              content.style.display = 'block';
        }
    	
    		
    	function HideThis(id) 
    	{
    	var content = document.getElementById(id)
    	content.style.display='none';
    	}
    </script>
    And this in the body:

    Code:
    <a href="#" onclick="HideThis('ivyinfo'); HideThis('ivygallery'); HideThis('ivycalendar'); toggle_visibility('ivyinfo'); return false;"
    
    <div id="ivyinfo" style="display:none; padding-left:10px;">Info Here</div>
    So what I want to be able to do is change the HideThis() function, so I can hide all of them in one statement, instead of separating them, I was thinking maybe HideThis('ivyinfo','ivygallery','ivycalendar') but it didn't work =/ Do you know how to achieve this?

    I also want the colour of the tab I've selected to change colour so you know you're on it.


    Jack

    Edit: Changed code
    Last edited by Schmoopy; 11-19-2008 at 09:49 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •