making a Horizontal Rule visible and not visible

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpmel
    New Member
    • Oct 2007
    • 69

    making a Horizontal Rule visible and not visible

    Hi Guys,

    Can a horizontal rule be visible and not visible within the <td> tag of a row on a table?
    Code:
     <tr>
           <td colspan="4" style="height: 20px; text-align: left" valign="middle">
                    <hr id ="hr" style="width: 75%" visible="false" >                 
             </td>
    </tr>
    I tried the above code and it is not working, the horizontal rule is always visible.
    i attached an id to it because i wanted to code when it should be visible or not.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Use:
    Code:
    <hr id="hr1" style="visibility:hidden; width:75%;" />
    Then you can change it with Javascript:
    Code:
    function showHide()
            {
                elem = document.getElementById("hr1");
                if(elem.style.visibility == 'hidden')
                    elem.style.visibility = 'visible';
                else   
                    elem.style.visibility = 'hidden';
            }
    Originally posted by phpmel
    Hi Guys,

    Can a horizontal rule be visible and not visible within the <td> tag of a row on a table?
    Code:
     <tr>
           <td colspan="4" style="height: 20px; text-align: left" valign="middle">
                    <hr id ="hr" style="width: 75%" visible="false" >                 
             </td>
    </tr>
    I tried the above code and it is not working, the horizontal rule is always visible.
    i attached an id to it because i wanted to code when it should be visible or not.

    Comment

    • phpmel
      New Member
      • Oct 2007
      • 69

      #3
      thank you, that works

      is there also a way to change it with c# using the id?

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Sure. Change it to:
        Code:
        <hr id="hr1" runat="server" style="visibility:hidden; width:75%;" />
        The 'runat="server" ' lets you manipulate it in the code. Here's how:

        Code:
        string value = hr1.Style["visibility"];
        if (value == "hidden")
            hr1.Style["visibility"] = "visible";
        else
            hr1.Style["visibility"] = "hidden";
        The difference between the C# version and the Javascript version is that the C# version will require a page refresh. The Javascript executes on the client side.

        Originally posted by phpmel
        thank you, that works

        is there also a way to change it with c# using the id?

        Comment

        Working...