×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    User:DrOwl/23meblog/showhide

    this is my first mod of the javascript i got from the blogger help site (used to show hide comments)

      function showhidediv (divid) { 
       whichpost = document.getElementById(divid);  
       if (whichpost.className=="divhidden") { 
          whichpost.className="divshown"; 
       } 
       else { 
          whichpost.className="divhidden"; 
       } 
      }
    
        .divhidden {display:none;}
        .divshown {display:inline;}
    
    <a title="Show or Hide" href="javascript:showhidedivnew('[div id]')">link</a>
    
    <div  class="divhidden" id="[div id]">text</div>
    


    i still have a major problem with the show hide script... in that when it changes the style to posthidden / postshown it also removes any other styles that were applyed to the element too i need to do some work on the javascript --phedocode :

    read existing style info (var=whichpost.className)
    check to see if "posthidden / postshown" are in className (if inStr ??)
    replace "posthidden / postshown" with "posthidden / postshown" (maybe with regEx or some such string)
    

    --User:DrOwl 05:17, 12 Mar 2005 (CET)

    javascript showhode problem fixed via a simpler methord then i thourght at first... just set the div to a hidden style, then use the java script to set the style you want to use for it.

    <head>
     <style type="text/css">
     <!--
    
        .divhidden {display:none;}
    
        .[div style] (color: #000000;}
    
      -->
      </style>
    
     <script type="text/Javascript"> 
    
      function showhidedivnew (divid,divclass) { 
       whichpost = document.getElementById(divid);  
       if (whichpost.className=="divhidden") { 
          whichpost.className=divclass; 
       } 
       else { 
          whichpost.className="divhidden"; 
       } 
      }
    
    <body>
    
    <a title="Show or Hide" href="javascript:showhidedivnew('[div id]','[div style]')">link</a>
    
    <div  class="divhidden" id="[div id]">text</div>
    

    --DrOwl 05:18, 13 Mar 2005 (CET)

    I guess this will work on non div elements too ie <p> <span> etc etc etc...

    =)

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.