嗨Java腳本函數,我有以下的Java腳本函數:如何通過ID在ASP.NET
function EnableDisableTextBox(chkBoxId, txtBoxId) {
var isChk = document.getElementById(chkBoxId);
document.getElementById(txtBoxId).disabled = !(isChk.checked);
}
當我試圖撥打以上功能,通過點擊複選框,其工作不正常
<asp:CheckBox ID="chkBachelors"
onclick="javascript:EnableDisableTextBox('chkBachelors','txtFirstDegree');"
runat="server" Text='<%$Resources:Resource, FirstDegree %>' TextAlign="Left"/>
<asp:TextBox ID="txtFirstDegree" CssClass="form-text" runat="server"
MaxLength="250"></asp:TextBox>
預期結果(當用戶點擊chkBachelors
複選框):
if "chkBachelors" check box is checked
then enable "txtFirstDegree" text box
else
disable "txtFirstDegree" text box
什麼問題以及如何解決?
哪個asp.net版本?你介意使用jQuery嗎? – naveen 2012-04-11 06:41:38