如何通过下拉列表项启用文本框 [英] how to enable textbox by dropdownlist items

查看:57
本文介绍了如何通过下拉列表项启用文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
i有一个下拉列表,其中我有一些名为男性和女性的物品。

我还有另一个文本框标记怀孕计数。

一旦我选择了女性那个怀孕计数应该启用。如果男性它应该禁用c#。

帮助我。

感谢提前。:)



这是我的源代码

< div id = R3C2 style = width:23%; height:7%; float:left; border:Solid 1px Black >
< asp:标签 ID = Gendr runat = server 文本 = 性别 >
< asp:DropDownList ID = DropDwnList1 runat = server

onselectedindexchanged = DropDwnList1_SelectedIndexChanged AutoPostBack = true >
< asp:ListItem > 男性
< asp:ListItem 已选择 = True > 女性

< / div >
< div id = R3C3 style = width:26%; height:7%; float:left; border:Solid 1px Black >
< asp:标签 ID = PrgncyCunt runat = 服务器 文字 = PregnancyCount >
< asp:TextBox ID = TextBox5 runat = server < span class =code-attribute> 宽度 = 15.8% >
< / div >

解决方案

您也可以使用jquery执行此操作:

 <   script     src   =  http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js >  <   /   script  >  

< script type = text / javascript >

document )。ready( function (){


' #gender')。change( function (){
var value =


hi i have one dropdownlist where i have items called male and female.
and i have another textbox labled pregnancy count .
once i select female that pregnanacy count should enable.if male it should disable using c#.
help me out.
thanks in Advance.:)

Here is my source code

<div id="R3C2" style="width:23%;height:7%;float:left;border:Solid 1px Black">
<asp:Label ID="Gendr" runat="server" Text="Gender">
<asp:DropDownList ID="DropDwnList1" runat="server"

onselectedindexchanged="DropDwnList1_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem >Male
<asp:ListItem Selected="True">Female

</div>
<div id="R3C3" style="width:26%;height:7%;float:left;border:Solid 1px Black">
<asp:Label ID="PrgncyCunt" runat="server" Text="PregnancyCount">
<asp:TextBox ID="TextBox5" runat="server" Width="15.8%">
</div>

解决方案

You can do this by using jquery also :

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

 <script type="text/javascript">


(document).ready(function(){


('#gender').change(function(){ var value =


这篇关于如何通过下拉列表项启用文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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