Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    show/hide + change text

    how can I do ? :

    <script type="text/javascript">
    function SH(me,id)
    {
    if(document.getElementById(me).innerHTML='Hide')
    {
    document.getElementById(me).innerHTML='Show';
    document.getElementById(id).style.display='none';
    }
    else
    {
    document.getElementById(me).innerHTML='Hide';
    document.getElementById(id).style.display='block';
    }
    }
    </script>
    </head>
    <body>
    <a href="#" onclick="SH(this,'S_H')">Show</a>
    <div id="S_H" style="display:none;">ok</div>
    </body>



    in a very esthetic way :-))

    thank you
    Last edited by angiras; 10-14-2003 at 02:04 PM.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'll explain my revision if you want. If you can figure it out w/o my explanation, even better!
    Code:
    <script type="text/javascript">
    function SH( me, id )
    {
        var you = document.getElementById( id );
        if( me.innerHTML == 'Hide' )
        {
            me.innerHTML = 'Show';
            you.style.display = 'none';
        }
        else
        {
            me.innerHTML = 'Hide';
            you.style.display = 'block';
        }
    }
    </script>
    </head>
    <body>
    <span onclick="SH(this,'S_H')">Show</span>
    <div id="S_H" style="display:none;">ok</div>
    </body>
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    !

    perfectissimo, ca marche ! wunderbar !

    it works !


    I have change it in that way :

    ---------------------------------------------

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title>titre</title>
    <script type="text/javascript">
    function SH(me,id,show,hide)
    {
    var you = document.getElementById( id );
    if( me.innerHTML == hide )
    {
    me.innerHTML = show;
    you.style.display = 'none';
    }
    else
    {
    me.innerHTML = hide;
    you.style.display = 'block';
    }
    }
    </script>
    </head>
    <body>
    <form id="MainForm">
    <span onclick="SH(this,'S_H','Open','Close');">Open</span>
    <div id="S_H" style="display:none;">ok</div>
    </form>
    </body>
    </html>

    -----------------------------------------------

    thank_you
    Last edited by angiras; 10-14-2003 at 03:39 PM.


  •  

    Posting Permissions

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