SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide Div on Click while also Showing a DIV

    Does anyone know how I can manage to do the following:
    http://www.myvouchercodes.co.uk/disc...totalpda.co.uk

    If you can see it shows one div when you click the button it hides that div and shows another whilst also launching a browser window below the current one. Anyone know how I can do that… I dont know javascript or enough css to do it.

    Cheers
    Robert
    Moxle.com | Wheres your profile?
    www.moxle.com

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have a closer look at the markup, that button has an onclick event which activates this function:

    Code:
    function showDealDetail(id, url)
    {
        document.getElementById('codehide'+id).style.display='none';
        document.getElementById('codeshow'+id).style.display='block';
        new_win = window.open(url,'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
    }
    First it sets the 'codehide' elements to display:none; (making it invisible)
    Then it sets the 'codeshow' element to display:block; (making it visible)
    The last line of the function opens the new window.

    Here is the call to the function: (in the anchor)

    Code:
    onclick="showCouponDetail('1','/discounts/details/totalpda.co.uk/11614'); return false;"
    The "return:false;" at the end makes sure that the browser does not navigate to the href of that anchor. The reason that there is an href is for those users without JS.

    Hope that helps...
    James Padolsey
    –––––––––––––––––––––––––––––––––––––––
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)


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
  •