Skip to content Skip to sidebar Skip to footer

Updating Html.dropdownlists Using Jquery

I found this solution on here How to update strongly typed Html.DropDownList using Jquery and am trying to implement it, but something is bugged in it. $(function() { $('#cid')

Solution 1:

Very bizzare, but i came up with a solution that i can break point through.

<scripttype="text/javascript">

        $(function () {
            $('#cid').change(function () {
                var coid = $(this).val();
                $.post("/TimeTracking/FilterFieldOffices", { companyId: coid }, function (data) {
                    $("#foid").loadSelect(data); 
                });
            });
        });

        $(function () {
            $.fn.loadSelect = function (data) {
                returnthis.each(function () {
                    this.options.length = 0;
                    $.each(data, function (index, itemData) {
                        var option = newOption(itemData.Text, itemData.Value);
                        this.add(option);
                    });
                });
            };
        });

    </script>

All i had to do was to wrap the function that wasnt being called in a $(function() { //Code here }); However im still having some trouble. I made a new page for it.

Refreshing a dropdownlist after elements have been reset

Post a Comment for "Updating Html.dropdownlists Using Jquery"