使用单选按钮隐藏显示文本框 [英] hide show text box using radio button

查看:85
本文介绍了使用单选按钮隐藏显示文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用2个单选按钮名称club,如果选中了club,则显示个人,如果选中了个人,则不显示文本框.

i am use 2 radio button name club and individual if club is checked show a text box if individual is checked not show the text box

推荐答案

使用此文档.getElementById(''controlid'').style.display =''none'';
隐藏
并取消隐藏使用此
document.getElementById(``controlid'').style.display =''block'';
use this document.getElementById(''controlid'').style.display=''none'';
to hide
and to unhide use this
document.getElementById(''controlid'').style.display=''block'';


在.aspx页面中

< asp:radiobuttonlist id ="rbl" runat ="server" onselectedindexchanged ="rbl_OnSelectedIndexChanged" autopostback ="true">
< asp:listitem text ="Club" selected ="True">
< asp:listitem text ="Individual">

< asp:textbox id ="txtC" runat ="server" text ="Club">
< asp:textbox id ="txtI" runat ="server" text ="Individual">

-------------------------------------------------- -------------------------
在.aspx.cs页面中

受保护的void Page_Load(对象发送者,EventArgs e)
{
txtI.Visible = false;
txtC.Visible = false;
}
受保护的void rbl_OnSelectedIndexChanged(对象发送者,EventArgs e)
{
如果(rbl.SelectedItem.Text =="Club")
{
txtI.Visible = false;
txtC.Visible = true;
}
否则,如果(rbl.SelectedItem.Text ==个人")
{
txtC.Visible = false;
txtI.Visible = true;
}
}


希望这能解决您的问题,
@Nidhish
In .aspx page

<asp:radiobuttonlist id="rbl" runat="server" onselectedindexchanged="rbl_OnSelectedIndexChanged" autopostback="true">
<asp:listitem text="Club" selected="True">
<asp:listitem text="Individual">

<asp:textbox id="txtC" runat="server" text="Club">
<asp:textbox id="txtI" runat="server" text="Individual">

---------------------------------------------------------------------------
In .aspx.cs page

protected void Page_Load(object sender, EventArgs e)
{
txtI.Visible = false;
txtC.Visible = false;
}
protected void rbl_OnSelectedIndexChanged(object sender, EventArgs e)
{
if (rbl.SelectedItem.Text == "Club")
{
txtI.Visible = false;
txtC.Visible = true;
}
else if (rbl.SelectedItem.Text == "Individual")
{
txtC.Visible = false;
txtI.Visible = true;
}
}


Hope this will solve your problem,
@Nidhish


使用JQuery尝试以下解决方案:您需要将JQuery文件添加到解决方案中.


< script type ="text/javascript" src ="jquery-1.6.js"></script>
< html xmlns ="http://www.w3.org/1999/xhtml">
< head runat ="server">
< script type ="text/javascript" language ="javascript">
Try below solution using JQuery: You need to add JQuery file to your solution.


<script type="text/javascript" src="jquery-1.6.js"></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" language="javascript">


这篇关于使用单选按钮隐藏显示文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆