如何使用radioButton lis禁用文本框 [英] How to disable textbox using radioButton lis
本文介绍了如何使用radioButton lis禁用文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请先生,
给我建议。
如何使用RadioButtonlist禁用文本框。
假设我在RadioButtonlist中有三个选项1-Cash 2-Check 3-Draft
我有三个textBox Bankname,Chequedate和chequeNo。
如果我选择现金
那么所有三个文本框都将被禁用。
但如果是2和3
然后将启用所有文本框。
在JavaScript中
谢谢
Ashish
Please Sir,
Give me Suggest.
How to disable textbox using RadioButtonlist.
Suppose I have Three option in RadioButtonlist 1-Cash 2-Cheque 3-Draft
and I have three textBox Bankname,Chequedate and chequeNo.
if I select Cash
then all three textbox will be disable.
but if case 2 and 3
then all textbox will be enabled.
in JavaScript
Thanks
Ashish
推荐答案
请检查此代码
Please check this code
function DisableTextBox() {
var buttonList = document.getElementById('<%=chkBoxList.ClientID %>');
var inputs = buttonList.getElementsByTagName("input");
var txtBox1 = document.getElementById('<%=txtBOX1.ClientID %>');
var txtBox2 = document.getElementById('<%=txtBOX2.ClientID %>');
var txtBox3 = document.getElementById('<%=txtBOX3.ClientID %>');
if (inputs[0].checked) {
txtBox1.disabled = true;
txtBox2.disabled = true;
txtBox3.disabled = true;
}
else {
txtBox1.disabled = false;
txtBox2.disabled = false;
txtBox3.disabled = false;
}
}
<asp:radiobuttonlist id="chkBoxList" runat="server" onclick="DisableTextBox(this);" xmlns:asp="#unknown">
<asp:listitem text="Cash" value="0" />
<asp:listitem text="Check" value="1" />
<asp:listitem text="Draft" value="2" />
</asp:radiobuttonlist>
<asp:textbox id="txtBOX1" runat="server" xmlns:asp="#unknown" />
<asp:textbox id="txtBOX2" runat="server" xmlns:asp="#unknown" />
<asp:textbox id="txtBOX3" runat="server" xmlns:asp="#unknown" />
您也可以尝试使用Jquey,代码行将减少谢谢。
you can attempt with Jquey too and line of code will be decreased Thanks.
这篇关于如何使用radioButton lis禁用文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文