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 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to make a textBox invisible using javascript

    hi

    i want to make my textbox invisible in certain cases, is it possible to do using javascript or by any other means

    thnx
    Murali.

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    yes it is.


    you can change the style of the object like so:
    Code:
    <input type=text id=text1>
    <input type=button value=hide onclick=hide()>
    <input type=button value=show onclick=show()>
    <script type=text/javascript>
    function hide(){
    document.getElementById('text1').style.visibility='hidden';
    }
    function show(){
    document.getElementById('text1').style.visibility='visible';
    }
    </script>
    the above is not cross-browser friendly though, as different browsers require different values to be set to the visibility.

    however comma though......

    you can change the display of the object:
    document.getElementById('text1').style.display="none"; //for hide
    document.getElementById('text1').style.display="block"; //for show


    there is a difference in the two ways. changing the objects visibility does just that, it still takes up the space it would if it were visible. where changing the display of an object hides it and all other objects around it fill in the space.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you..brandon


  •  

    Posting Permissions

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