本帖最后由 just_even 于 2009-06-17 11:03:10 编辑

解决方案 »

  1.   


    <asp:Panel ID="Panel1" runat="server" > 
    <asp:RadioButton ID="rbtQ1_1" runat="server"  Text="是"  GroupName="Q1"  /> 
    <asp:RadioButton ID="rbtQ1_2" runat="server"  Text="否"  GroupName="Q1"  /> 
    <asp:RadioButton ID="rbtQ1_3" runat="server" Text="其他"  GroupName="Q1"  onclick="ShowTextbox(this); /> 
    <asp:TextBox ID="txtQ1" runat="server"  style="display:none;" > </asp:TextBox> 
    </asp:Panel> <script language="javascript"> 
    function ShowTextbox(obj) 
        { 
            var txtBox=document.getElementById("txtQ1"); 
            txtBox.style.display=obj.checked?"":"none"; 
            if(txtBox.style.display=='none') 
            { 
                txtBox.value=""; 
            } 
        } 
    </script>
    似乎写的没错啊……
      

  2.   

    每个RadioButton的点击事件都执行一次你的ShowTextbox()
    稍改下<script language="javascript"> 
        function ShowTextbox() 
        { 
            var txtBox=document.getElementById("txtQ1"); 
            txtBox.style.display=document.getElementById("rbtQ1_3").checked?"":"none"; 
            if(txtBox.style.display=='none') 
            { 
                txtBox.value=""; 
            } 
        } 
    </script>另外,我执行你的代码不能实现,你用的服务器端RadioButton控件,他不认onclick脚本事件
    我换了下,你试试<body>
    <script language="javascript" type="text/javascript"> 
        function ShowTextbox() 
        { 
            var txtBox=document.getElementById('txtQ1');
            txtBox.style.display=document.getElementById("rbtQ1_3").checked?"":"none"; 
            if(txtBox.style.display=='none') 
            { 
                txtBox.value=""; 
            }
        } 
    </script>
    <form id="form1" runat="server"> 
        <div>
            <asp:Panel ID="Panel1" runat="server" >
                <input id="rbtQ1_1" type="radio" onclick="ShowTextbox()" name="Q1" />是
                <input id="rbtQ1_2" type="radio" onclick="ShowTextbox()" name="Q1" />否
                <input id="rbtQ1_3" type="radio" onclick="ShowTextbox()" name="Q1" />其他
                <asp:TextBox ID="txtQ1" runat="server"  style="display:none;" > </asp:TextBox> 
            </asp:Panel> 
        </div>
    </form>
    </body>