SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member rotarjen's Avatar
    Join Date
    Apr 2008
    Location
    Colorado
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Replace data when clicking on image map

    Hello
    I have a US map set up as an image map. When I click each state, I want to display a set of results specific to that state in an area next to the map.

    If another state is clicked, the previous info should be hidden and new state data will appear.
    Currently I have this working so that all data stacks up next to each other, and you can manually close each state, however it doesn't replace old data with new.

    Here it is in action: http://www.nowindev.com/commercial.asp
    NOTE: ONLY CALIFORNIA, OREGON, WASHINGTON, IDAHO & NEBRASKA ARE CODED SO FAR. NO OTHER STATES ACTIVE YET.

    Any ideas on how I can automatically hide one state's data when I click on a new state?
    Jen

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,097
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    Change your 'showhide' function to this:

    Code:
    <script>
    var showing = undefined;
    function showhide(id){
      if (id==showing) return;
      if (document.getElementById){
        obj = document.getElementById(id);
        if (obj.style.display == "none"){
          if (showing != undefined)
          {
             document.getElementById(showing).style.display = "none";
          }
          showing = id;
          obj.style.display = "block";
        } else {
          obj.style.display = "none";
        }
      }
    }
    </script>
    That should do the trick

  3. #3
    SitePoint Member rotarjen's Avatar
    Join Date
    Apr 2008
    Location
    Colorado
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AWESOME - it works perfectly! You've just saved me from a long weekend of trying to figure this out.
    You are my new best friend!
    Jen


Tags for this Thread

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
  •