SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile How can i hide a text box? When...

    Hi,

    I have 2 radio buttons as fallow:

    <input type="radio" name="test" value="Yes" checked>Yes
    <input type="radio" name="test" value="No">No

    And a text box:

    <input type="text" name="cnl" size="30">

    I want to hide the text box when the user choose "No" and show it when he choose "Yes".

    How can i do that?

    Thanks...
    Why It Doesn't Work?!

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe you could do something along the lines of:

    document.formname.element.style.visibility = 'hidden';

    However hiding the box does not conform with commonly accepted user interface standards, and as such may confuse some users... not to mention that it will most certainly not work the same on all browsers.

    The preferred method would be to disable the text box, rather than hiding it. This is accomplished by setting the element's disabled property to true.

    This will be far more cross-browser compatible, as well as being more congruent with the rest of the software/OS/web apps that your viewers use.


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
  •