级联下拉列表不起作用
我尝试更改级联下拉列表示例 http://www.codedigest.com/Articles/ jQuery/224_Building_Cascading_DropDownList_in_ASPNet_Using_jQuery_and_JSON.aspx
但我总是收到消息“Microsoft JScript 运行时错误:预期对象”
也许有人有想法?
<asp:Content ID="Content1" ContentPlaceHolderID="contentplaceholderHEAD" runat="Server">
</script src="~/_scripts/jQuery-1.4.2.js" type="text/javascript">
<script language="javascript">
$(document).ready(function () {
$("#<%=Ticket_ArtDropDownList.ClientID %>").change(function() {
$("#<%=Ticket_StatusSelect.ClientID %>").html("");
var Ticket_Art = $("#<%=Ticket_ArtDropDownList.ClientID %> > option:selected").attr("value");
if (Ticket_Art != 0) {
$.getJSON('Ticketdetails.ashx?Ticket_Art=' + Ticket_Art, function(cities) { //wozu dient dieses "cities" ?
$.each(cities, function() {
$("#<%=Ticket_StatusSelect.ClientID %>").append($("</option>").val(this['Ticket_Art']).html(this['Text']));
});
});
}
});
});
</script>
无法将我的所有代码标记为“Sourceode”,因为它无法正常工作。
<asp:Content ID="Content2" ContentPlaceHolderID="maincontent" runat="Server">
<div>
票证_ID: 门票_艺术: 票证状态:
i tried to change an cascading dropdownlist example http://www.codedigest.com/Articles/jQuery/224_Building_Cascading_DropDownList_in_ASPNet_Using_jQuery_and_JSON.aspx
But i get always the message "Microsoft JScript runtime error: Object expected"
Maybe someone has an idea?
<asp:Content ID="Content1" ContentPlaceHolderID="contentplaceholderHEAD" runat="Server">
</script src="~/_scripts/jQuery-1.4.2.js" type="text/javascript">
<script language="javascript">
$(document).ready(function () {
$("#<%=Ticket_ArtDropDownList.ClientID %>").change(function() {
$("#<%=Ticket_StatusSelect.ClientID %>").html("");
var Ticket_Art = $("#<%=Ticket_ArtDropDownList.ClientID %> > option:selected").attr("value");
if (Ticket_Art != 0) {
$.getJSON('Ticketdetails.ashx?Ticket_Art=' + Ticket_Art, function(cities) { //wozu dient dieses "cities" ?
$.each(cities, function() {
$("#<%=Ticket_StatusSelect.ClientID %>").append($("</option>").val(this['Ticket_Art']).html(this['Text']));
});
});
}
});
});
</script>
Can't tag all my code as "Sourceode" because its not working corectly..
<asp:Content ID="Content2" ContentPlaceHolderID="maincontent" runat="Server">
<div>
Ticket_ID:
Ticket_Art:
Ticket_Status:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说最突出的是你的脚本标签...我不相信 jQuery 被正确包含,这:
应该是:
还要检查你的源代码,确保
~/
被解析为最终 HTML 中的正确目录。同样在循环中,$("")
应该是:$("
。最后一个建议是您可以直接在
What stands out at me is your script tag...I don't believe jQuery is being included correctly, this:
Should be:
Also check your source, make sure the
~/
is being resolved to the correct directory in the final HTML. Also in your loop,$("</option>")
should be:$("<option/>")
.The last suggestion is you can use
.val()
directly on a<select>
to get the current value, like this: