Yii2 Ajax onChange onBlur load product items details

$("input[id='acceptapplication-mouja']").replaceWith('');
            //$("input[id='acceptapplication-j_l_no']").replaceWith('');

            $("select[id*='sub_district']").change(function(){

                var subDistrictId = $("select[id*='sub_district']").val();
//
                $("input[id='acceptapplication-mouja']").replaceWith('');
//                $("input[id='acceptapplication-j_l_no']").replaceWith('');
//


                $.ajax({
                    url: 'getUrlManager()->createUrl("acceptapplication/getmoujajlno") ?>' ,
                    data: { id : subDistrictId },
                    type : 'POST',
                    success: function (json) {
//                        $("#acceptapplication-mouja").remove();
//                        $("#acceptapplication-j_l_no").remove();

                        var selectOptionsMouja = " Select Mouja ";
                        //var selectOptionsJLNo = "";
                        var jsona = JSON.parse(json);

                        $.each(jsona,function(i,m){

                            selectOptionsMouja += ""+ m.mouja +"";
                            //selectOptionsJLNo =  m.j_l_no ;

                        });

                        $("#acceptapplication-mouja").empty().append(selectOptionsMouja);
                        //$("#acceptapplication-j_l_no").val(selectOptionsJLNo);

                    }
                });
            });


            $("#acceptapplication-j_l_no").blur(function(){

                var JLNo = $("#acceptapplication-j_l_no").val();

                $.ajax({
                    url: 'getUrlManager()->createUrl("acceptapplication/getmoujas") ?>' ,
                    data: { id : JLNo },
                    type : 'POST',
                    success: function (json) {

                        var obj = JSON.parse(json);

                        var selectOptionsMouja = " " + obj.mouja +"";

                        $("#acceptapplication-mouja").append(selectOptionsMouja);

                    }
                });
            });


            $("#acceptapplication-mouja").change(function(){

                var mouja = $("#acceptapplication-mouja").val();

                $.ajax({
                    url: 'getUrlManager()->createUrl("acceptapplication/getjlnos") ?>' ,
                    data: { id : mouja },
                    type : 'POST',
                    success: function (json) {

                        var obj = JSON.parse(json);

                        var selectOptionsJLNo = obj.j_l_no ;

                        $("#acceptapplication-j_l_no").val(selectOptionsJLNo);

                    }
                });
            });

        });


    

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s