SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Birmingham UK
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Show/Hide Layer with text links

    How do I show and hide a layer with a text link?

    Obviously need some Javascript code but not sure of the proper syntax to make it work.

    Its for a menu.

    Thanks,
    Si

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    like this

    PHP Code:
    <script>

    function 
    SwitchIt(id)
    {
        if (
    id !=null)
        {
            if (
    document.getElementById(id).style.display=='block')
            {
                 
    document.getElementById(id).style.display='none';
            }
            else
            {    
                
    //eval("document.getElementById(id).style.display='none';");

                
    document.getElementById(id).style.display='block';
            }
        }
    }

    </script>
    <div id="me" style="display:show"> 
        <a href="javascript:void(0)" onclick="SwitchIt('menu')">hide</a>
    </div>

    <div id="menu" style="display:none"> 
        <a href="javascript:void(0)" onclick="alert('from hidden menu')">menu 1</a>
    </div> 

  3. #3
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    different approach

    Sorry, i have to be different as per usual

    Example:
    Code:
    <s>
    var tO=this.offsetParent.lastChild;
    </s>
    <td>
     <span onclick="hand" onclick="(tO.display=='')?tO.display='none':tO.display='';">
         SHOW DIV
     </span>
     <div style="display:none">
      This is a nameless Div<br>
     </div>
    </td>
    Don't know whether or not this applies.. but i'd thought i'd offer my thoughts

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe, "as per usual " I can't seem to get your method working lol.

    I tried to do something similir to this earlier

    Code:
    var tO=this.offsetParent.lastChild;
    but it didn't like this in a variable am I messing it up "as per usual"

  5. #5
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sorry

    You should know i don't crash test my theories, i only push people in the right direction:

    http://www.passway.org/AJ2.html

    Code:
    <table>
    <tr>
     <td>
      <span onclick="var tO=this.offsetParent.lastChild.style;(tO.display=='')?tO.display='none':tO.disp
    lay='';" style="cursor:hand">
          SHOW DIV
      </span>
      <div style="display:none">
       This is a nameless Div<br>
      </div>
     </td>
     </tr>
    </table>
    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •