Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
how to add items to WebDropDown using javascript
posted

Hi i have two WebDropDown control in my form. one is state and another one is city. i selected state means corresponding city loaded to city WebDropDown using javascript. i wrote a code but i got error like "Microsoft JScript runtime error: Unable to get value of the property '_callbackManager': object is null or undefined"

My Code is :

function LoadDropDown() {
            var ddlState = $find('ddlState');

            var Tamilnadu = new Array('--Select--', 'Salem', 'Coimbatore', 'Karur');
            var Kerala = new Array('--Select--', 'Kochin', 'Palakad', 'Kollam');

            var ddlCity = $find('ddlCity');

            switch (ddlState.get_currentValue()) {
                case 'Tamilnadu':

                    for (var i = 0; i < Tamilnadu.length; i++) {
                        var item = ddlCity.get_items().createItem();
                        item.set_text(Tamilnadu[i].toString());
                        item.set_value(i);
                        ddlCity.get_items().add(item);
                        ddlCity.set_selectedItemIndex(0)
                    }
                    break;

                case 'Kerala':

                    for (var i = 0; i < Kerala.length; i++) {
                        var item = ddlCity.get_items().createItem();
                        item.set_text(Kerala[i]);
                        item.set_value(i);
                        ddlCity.get_items().add(item);
                    }
                    break;

                default:
                    ddlCity.options.length = 0;
                    break;
            }
        }

Kindly help me someone please.

Thanks.

Parents
No Data
Reply Children
No Data