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 2 of 2
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up please help me with the change title and show/hide text java-script

    code is a little bit long (tens of lines), so I upload it to somewhere.

    please click the link
    http://www.syncedit.com/zzz/single.html
    to see my question.

    please ask if my question is not clear.

    thanks

    .
    Last edited by hello20109876; 05-07-2006 at 11:27 AM.

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,503
    Thanks
    3
    Thanked 500 Times in 487 Posts
    Code:
    <html>
    <head>
    
    <script>
    //---------------------- code for swap text
    var lst;
    function swapText(p_element, p_text1){
     if (!p_element.txt){ p_element.txt=p_element.innerHTML; }
     menuitem=p_element.parentNode.getElementsByTagName('DIV')[0];
     (p_element.innerHTML==p_text1)?p_element.innerHTML=p_element.txt:p_element.innerHTML=p_text1;
     if (!menuitem){ return; }
     menuitem.lk=p_element;
     if (!menuitem.set){
      menuitem.style.display='';
      menuitem.set=true;
     }
     else {
      menuitem.style.display='none';
      menuitem.set=false;
     }
    // temove these lines if do not wish to clase lst
     if (lst&&menuitem.set){ lst.style.display='none'; lst.set=false; lst.lk.innerHTML=lst.lk.txt}
     lst=menuitem;
    }
    
    
    
    </script>
    
    <style type="text/css">
     .span0
    
    {
    font-size:18px;
    font-weight:bold;
    color:ff0000;
    }
    </style>
    
    
    </head>
    
    <body>
    (Please see <b><font color="#008000">Explain</font></b> bellow first)
    
    <br>
    <br>
    <span id="tempcontainer" class="mainDiv" style="visibility: hidden; position: absolute"></span>
    
    <b>Part 1:</b> ----- click on red text <b>more</b> to change it (title) to <b>less</b>
    <br>
    <a>Click <span CLASS="Span0" onclick='swapText(this,"... less");'>... more</span> or visit ...
    </a>
    <br>
    <br>
    <b>Part 2:</b> ----- click on red text <b>more</b> bellow to show/hide hidden text
    <br>
    <a>
    Click <span CLASS="Span0" onclick='swapText(this,"... less");'>... more</span> or visit ...
    <div style="display:none;" state="0">
    			Go to <a href="http://www.google.com.au/" target="_new">google</a>
    			<br>
    			Go to <a href="http://www.google.com.au/" target="_new">google</a>
    
    			<br>
    </div>
    </a>
    <br>
    <br>
    <b>Part 3:</b> ----- combination of Part 1 and Part 2: change and show/hide text.
    <br>
    but hidden text can not be shown - only change title is OK.
    <br>
    <a>Click <span CLASS="Span0" onclick='swapText(this,"... less");'>... more</span> or visit ...
    <div style="display:none;" state="0">
    Go to <a href="http://www.google.com.au/" target="_new">google</a>
    <br>
    Go to <a href="http://www.google.com.au/" target="_new">google</a>
    </div>
    </a>
    <br>
    <b>
    
    </body>
    
    </html>
    Last edited by vwphillips; 05-07-2006 at 03:56 PM.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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