日期:2014-05-18  浏览次数:20664 次

请教一个radio选中的问题
两个radio第一个选中禁用某个文本框 第二个选中再启用该文本框 来回选择不能出错 

用什么事件最合适 

如何写js

------解决方案--------------------
HTML code

<html>
<head>
    <title>Sample</title>
    <script type="text/javascript">
        function change(){
            var _text=document.getElementById("text");
            if(radio[0].checked){
                _text.disabled=true;
            }
            if(radio[1].checked){
                _text.disabled=false;
            }
        }
    </script>    
</head>
<body>
    <input type=radio name="radio" CHECKED onclick="change();" />First
  <input type=radio name="radio" onclick="change();" />Second
  <br/>
  <input type="text" id="text" value="文本框" disabled="true"/>
  
</body>
</html>