SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide div element

    Hi guys,

    I am trying to hide a div element by default, and have it appear on condition. I am using:

    Code:
                <script type="text/javascript">
        function order_publications() {
        var op = document.getElementById("order_publications");
            op.visible = false;
            op.style.visibility="hide";
            if (qsParm['title']) {
                order_publications.visible = true;
            }
        }
                </script>
    <div id="order_publications" runat="server" style="background-image:url('./../App_Themes/images/order_publication.png');background-repeat: no-repeat;width:717px; height:470px">
    but can not make it work... Am I doing anything wrong?
    Looking for partners/sales people advertising & content deals

  2. #2
    SitePoint Wizard webcosmo's Avatar
    Join Date
    Oct 2007
    Location
    Boston, MA
    Posts
    1,429
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    op.style.visibility="hide";

    this should be op.style.visibility="hidden";

  3. #3
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Does it have to be client-side? It'd work much more reliably server-side (IOW it will still work with javascript turned off).

  4. #4
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,868
    Mentioned
    37 Post(s)
    Tagged
    0 Thread(s)
    Yes, u are doing something wrong. That div is a runat server control, which means the ID is not "order_publications" anymore and is not probably something like "ctl00_ContentPlaceHolder1_order_publications". Check the source of the page to see wat it is. Or do this: var op = document.getElementById('<&#37;=order_publications.ClientID %>');

    But you should be using some library like jQuery and get the element via its class or id


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
  •