SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    style.visibility problem

    I have a script like this :

    script type="text/javascript" language="javascript">
    function ToggleVisibility(cbo1, lbl1)
    {
    alert("sid" + lbl1);

    lbl1.style.visibility='hidden';

    cbo1.style.visibility='visible';


    }

    </script>


    But, it give me an error style.visibility is null or not an object. cbo1 and lbl1 has the right values. Pls help.

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cbo1 and lbl1 has the right values
    No they don't.

    You're probably passing the ID of objects to this function (if not this line:
    alert("sid" + lbl1);
    would display an alert with the following text: sidObject object
    )
    but this function expects objects.

    Try this:
    Code:
    function ToggleVisibility(cbo1, lbl1)
    { 
    alert("sid" + lbl1); 
    
    document.getElementById(lbl1).style.visibility='hidden';
    
    document.getElementById(cbo1).style.visibility='visible';
    
    
    }

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How to get, the number of Items in a DropDown box?

    I am using

    document.getElementById(cbo1).options.count, but getting 'undefined'.

    Pls help.

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Resolved it by using :

    document.getElementById(cbo1).length;


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
  •