代碼應該在頁面加載時隱藏文本框,並且僅當用戶選擇「其他」時才使其可見。這個jquery驗證碼有什麼問題?
<script type="text/javascript">
$(document).ready(function() {
$('#ddlMajor').change(function() {
if ($(this).val() == 'Other') {
// $('#txtOther').show();
$('#txtOther').css('display', 'inline');
}
else {
// $('#txtOther').hide();
$('#txtOther').css('display', 'block');
}
});
});
</script>
<asp:TextBox runat="server" ID="txtOther" style="display:none;" > </asp:TextBox>
<asp:DropDownList runat="server" ID="ddlMajor">
<asp:ListItem Value="Accounting">Accounting</asp:ListItem>
<asp:ListItem Value="Management">Management</asp:ListItem>
<asp:ListItem Value="Other">Other</asp:ListItem>
</asp:DropDownList>
目前它做什麼? –
你可以顯示由asp.net代碼生成的HTML嗎? –
我不認爲您在ASP中設置的ID:dropdownList與生成的HTML中生成的ID相同。當你使用Firebug或IE調試器等工具查看時,你會得到什麼? –