选中RadioButton时候显示一旁的textbox,取消选中时,隐藏此textbox如何实现? 本帖最后由 just_even 于 2009-06-17 11:03:10 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <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>似乎写的没错啊…… 每个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> 有关sqldataadapter的问题 在Page_Load中创建的TextBox何时回填视图数据 做完的界面在不用的浏览器 显示效果不一样怎么办 为什么自己做的网页总是不能通过IP地址访问 SQL Server 2005 怎么样导入数据呀? 一个简单的aps.net问题(在线等) 大量文件的解决方案 询问关于IMAGE问题 奇怪问题,连ACCESS数据库时在一台机器上就好用,另外一台就不行。 请教一段语句的C#写法 请高人指点,如何获取GridView中,当前行的上一行或下一行的数据值 web 下 使用Express控件问题来者有分
<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>
似乎写的没错啊……
稍改下<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>