我真的很难用javascript编程,需要帮助。
我正在尝试禁用网格视图中的6个下拉列表客户端。下面是我当前的javascript,除了我试图禁用其中一个下拉列表的最后一行。我认为问题是因为下拉列表在gridview中,java无法找到它们。我怎么找到它们?
<script>
function EnableAndColorButtons() {
document.getElementById('<%= Submit.ClientID %>').disabled = false;
document.getElementById('<%= Submit.ClientID %>').style.background = "Lime";
document.getElementById('<%= Submit.ClientID %>').style.borderColor = "Green";
document.getElementById('<%= Cancel.ClientID %>').disabled = false;
document.getElementById('<%= Cancel.ClientID %>').style.background = "lightcoral";
document.getElementById('<%= Cancel.ClientID %>').style.borderColor = "Red";
document.getElementById('<%= InfoLbl.ClientID %>').innerHTML = '(Continue to make changes or click submit if finished)';
document.getElementById('<%= MakeChangeslbl.ClientID %>').innerHTML = 'You must click "Submit Changes" or "Cancel Changes" above before making Assignment changes below!';
//The above is working, but the below is not probaly because the drop down lists are within gridview1
document.getElementById('<%= DropDownList1.ClientID %>').disabled = true;
}
</script>
我的Gridview下拉列表的位置如下所示:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" DataTextField="FullDetails" DataValueField="FullDetails" Font-Size="Medium" Height="50px" OnDataBinding="DropDownlist1_DataBinding1" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
答案 0 :(得分:0)
我终于找到了解决方案!!!
我所做的是右键点击带有Chrome浏览器的投递箱,然后点击了检查元素。在那里,我发现Dropbox的id等于&#34; GridView1_DropDownList1_0&#34;。
然后我在我的Javascript中执行了以下操作,它确实有效!
var ddl1 = document.getElementById("GridView1_DropDownList1_0");
ddl1.disabled = true