PHP相关_几个操作记录下

1.JSON转换

var cloneTesttaskList = <?php echo json_encode(json_encode($cloneTesttaskList));?>;
var cloneObjs = JSON.parse(cloneTesttaskList);

 

2.遍历Json对象

    for(var key in usersObjs) {
//        alert(key+":"+usersObjs[key]);
        $("#owner").find("option[value='" + key +  "']").attr("selected", false);
        $("#mailto").find("option[value='" + key + "']").attr("selected", false);
    }

 

3.js设置selector选中项并刷新(chosen

    $("#owner").find("option[value='" + cloneObjs[chosedNum].owner +  "']").attr("selected",true); 
//  $('#owner').trigger("chosen:updated");
    $('#owner').trigger("liszt:updated");
//  $("#owner").find("option[value='flx_test']").attr("selected",true); 
    
//    alert(cloneObjs[chosedNum].mailto);
//    alert($('#mailto').find("option:selected").val());  
//    $('#mailto').find("option:selected").val("");
    var emailSplit = cloneObjs[chosedNum].mailto.split(",");
    for(var i = 0; i < emailSplit.length; i++) {
        if(emailSplit[i] != "") {
            $("#mailto").find("option[value='" + emailSplit[i] + "']").attr("selected",true); 
        }
    }
//  $('#mailto').multiselect("refresh");
    $('#mailto').trigger("liszt:updated");

 

posted @ 2019-10-14 18:24  流浪_归家  阅读(214)  评论(0编辑  收藏  举报