views:

36

answers:

2

Hello,

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:

+1  A: 

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();
Nick Craver
Hello, the code-tag in my post converts <script> </script> to </script> and the option tag to </option>. But you where right. The path to the jQuery File was wrong. Now i'm not getting the Object inspected Error. But the cascading dropdownlist doesn't work.
float
I'm not getting to the script code when i try to use the debugger. Is there something wrong with the event handler?
float
Firebug has a Problem with this Line: $("#<%=Ticket_StatusSelect.ClientID %>").append($("<option></option>").val(this['Ticket_Art']).html(this['Text']));
float
Ticket_Art must be Ticket_Status
float
A: 
  • Path to jQuery File was not correct.
  • setting the options was not correct. There was no Ticket_Art but Ticket_Status in the response.
float