开发者

Cascading dropdownlist not working

开发者 https://www.devze.com 2023-01-17 02:41 出处:网络
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

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?

<as开发者_开发问答p: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:


What stands out at me is your script tag...I don't believe jQuery is being included correctly, this:

</script src="~/_scripts/jQuery-1.4.2.js" type="text/javascript">

Should be:

<script src="~/_scripts/jQuery-1.4.2.js" type="text/javascript"></script>

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:

var Ticket_Art = $("#<%=Ticket_ArtDropDownList.ClientID %>").val();


  • Path to jQuery File was not correct.
  • setting the options was not correct. There was no Ticket_Art but Ticket_Status in the response.
0

精彩评论

暂无评论...
验证码 换一张
取 消