Ignore:
Timestamp:
Mar 27, 2015 9:49:55 AM (10 years ago)
Author:
namnd
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/assets/js/frontend/user.js

    r820 r838  
    11function updateInfo(us_id) {
    22    $.ajax({
    3         url: 'update_user/' + us_id,
     3        url: '/frontend/user/update_user/' + us_id,
    44        type: 'POST',
    55        data: $("#frm1").serialize(),
     
    4242                $("#account-info-tab").click();
    4343            });
     44                       
     45                       
     46                        if ($(".form-field-province").val() !== 'undefined'){
     47                                checkSelecteDistrict();
     48                        }
     49                        $(".form-field-province").change(function(){
     50                                changeEventProvince();
     51                        });
     52                       
     53                       
     54                       
    4455            $("#finish_package_register").click(function () {
    4556                finish_package_register();
     
    274285        return x1 + x2;
    275286}
     287
     288function checkSelecteDistrict(){
     289        provinceId = $(".form-field-province").val();
     290        $.ajax({
     291        url: '/frontend/user/getDistrict/' + provinceId,
     292        type: 'POST',
     293        success: function (data, textStatus, jqXHR)
     294        {
     295            result = jQuery.parseJSON(data);   
     296                        content = "";
     297                        if (result != null){
     298                                for (var i in result){
     299                                        if (result[i].district_id === district_id){
     300                                                content = content + '<option value="' + result[i].district_id + '" selected >' + result[i].type + " " + result[i].district_name + '</option>';
     301                                        }else{
     302                                                content = content + '<option value="' + result[i].district_id + '">' + result[i].type + " "  + result[i].district_name + '</option>';
     303                                        }
     304                                }
     305                                $(".form-field-district").html(content);
     306                        }
     307        }
     308    });
     309}
     310
     311if ($(".form-field-province").val() !== 'undefined'){
     312        checkSelecteDistrict();
     313}
     314
     315function changeEventProvince(){
     316        $(".form-field-district").html("");
     317        provinceId = $("#form-field-province").val();
     318        $.ajax({
     319        url: '/frontend/user/getDistrict/' + provinceId,
     320        type: 'POST',
     321        success: function (data, textStatus, jqXHR)
     322        {
     323            result = jQuery.parseJSON(data);
     324                        content = "";
     325                        if (result != null){
     326                                for (var i in result){                 
     327                                        content = content + '<option value="' + result[i].district_id + '">'+ result[i].type + " "  + result[i].district_name + '</option>'
     328                                }
     329                                $(".form-field-district").html(content);
     330                        }
     331        }
     332    });
     333}
     334
     335$(".form-field-province").change(function(){
     336        changeEventProvince();
     337});
Note: See TracChangeset for help on using the changeset viewer.