Java Script for FAQ section E.g. provided

Discussion in 'JavaScript' started by indiarahul, Apr 15, 2009.

  1. #1
    Hi

    I would like to if anyone of you an help me find a javascript for my websites FAQ section I want to use the some what the same script as used by http://www.megaupload.com/?c=faq

    Looking forward for your help
     
    indiarahul, Apr 15, 2009 IP
  2. fex

    fex Peon

    Messages:
    89
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Look in it's source code, it's right there :confused:
     
    fex, Apr 15, 2009 IP
  3. Ristaki

    Ristaki Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It's easy :)

    <script>
    var image = { "on" : "images/on.png", "off" : "images/off.png" }
    
    function toggleContent(divId, imageId){
    
    if(document.getElementById(div).style.display == 'none'){
    document.getElementById(div).style.display = 'block';
    document.getElementById(imageId).src = image['off'];
    }else{
    document.getElementById(div).style.display = 'none';
    document.getElementById(imageId).src = image['on'];
    }
    
    }
    
    </script>
    Code (markup):
    The usage is this:
    
    <a href='#' onClick='toggleContent("info1", "infoImage1")'><img src='images/on.png'> Show Info</a>
    <div id="info1">Some Info</div>
    
    Code (markup):
    :)
     
    Ristaki, Apr 19, 2009 IP