Textbox appears and disappears with radio buttons

Discussion in 'JavaScript' started by scratcher, Jan 22, 2008.

  1. #1
    Hello,

    I am trying to get a text box to appear when a radio button is checked. Then dissapear when another radio button is checked. Is this possible at all?

    Thank you
     
    scratcher, Jan 22, 2008 IP
  2. tcardoso

    tcardoso Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can do it in several ways! Search about display (none, block, inline).
     
    tcardoso, Jan 22, 2008 IP
  3. webexpert

    webexpert Banned

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    try this, it will help you hopefully...

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1255 ">
    <script type="text/javascript">
    function michal(x) {
    var checky=document.getElementById(x);
    if (checky.checked) {
    idan.comments1.style.display="none";
    }
    else {
    idan.comments1.style.display="block";

    }
    }
    </script>
    </head>

    <body>
    <form id="idan">
    <input type="checkbox" id="check1" onclick="michal('check1')" checked /><textarea id="comments1" cols="30" rows="7">I think that</textarea>
    <br>

    </form>
    </body>
    </html>
     
    webexpert, Jan 22, 2008 IP