Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
    <form method="get" action="/cgi-bin/form.cgi" enctype="application/x-www-form-urlencoded" id="frm-whatever">
        <input type="radio" name="opttype" value="A:"/>A:
        <input type="radio" name="opttype" value="B:"/>B:
        <input type="radio" name="opttype" value="C:"/>C:
        <input type="radio" name="opttype" value="D:" id="btn-toggle"/>D:
        <br>
        <input type="tbox" name="event" id="inp-tbox"/><br>
        <textarea name="tarea" rows="8" cols="80" style="width:580;height:130;display:none;" id="inp-tarea"></textarea>
    <form>
</body>
</html>
 
      var toggleFields = (function() {
        var inpRecent  = document.getElementById("inp-tbox"),
                inpSpecificPost = document.getElementById("inp-tarea");
        
            return function(node) {
                if ( node.value == "D:" ) {
                    inpTxtArea.style.display = 'block';
                    inpTxtBox.style.display  = 'none';
                } else {
                    inpTxtArea.style.display = 'none';
                    inpTxtBox.style.display  = 'block';
                }
            };
        })();
      
        var radios = document.getElementById("frm-whatever").opttype;
        for ( var i=0, l=radios.length; i<l; ++i ) {
            radios[i].onchange = (function(i) {
                return function() {
                    toggleFields(radios[i]);
                }
            })(i);
        }  
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers