zoukankan      html  css  js  c++  java
  • 循环遍历取不同层级元素的值,以及json数据的拼接

    //提交处罚完整内容
    function submitPunish(){
    //1、获取需要提交的内容 项目id 表格行id 处罚对象id 处罚方式id
    projectId = $("#punishProjectId").val();
    var rowId = $("#warningTable").datagrid("getSelected").id;//alertId
    var punishUlLength = $("#punish>ul").length;
    //2、循环有多少个处罚$("#punish>ul").length;
    var handler = "[";
    var objectsId = "";
    var objectsName = "";
    for(var i = 0 ; i <punishUlLength ; i++){
    var remark = $("#punish .punishUl"+i+">.punishRemark"+i+" textarea").val();
    var punishWayId = $("#punish .punishUl"+i+" .dealWay"+i+" option:selected").attr("value");
    return false;
    var punishMoney = $(".punishMoney"+i+" input").val();
    var punishLiLength = $("#punish>.punishUl"+i+">.punishObjects"+i+">ul").length;
    //3、循环每个处罚对象里面有多少个处罚对象$("#punish>.punishUl"+i+">.punishObjects"+i+">ul").length;
    for(var j = 0;j <punishLiLength ; j++ ){
    alert("每个处罚对象里面有多少个处罚对象:"+punishLiLength);
    var objectId =$("#punish>.punishUl"+i+">.punishObjects"+i+">ul").eq(j).find("input[type='hidden']").val();
    var objectName =$("#punish>.punishUl"+i+">.punishObjects"+i+">ul").eq(j).find("input[type='hidden']").next().html();
    alert("处罚对象id:"+objectId + "对象名称:"+objectName);
    objectsId = objectsId + objectId + ",";
    objectsName = objectName + ","+ objectsName;
    console.log("所有处罚对象id:"+objectsId);
    console.log("所有处罚对象名称:"+objectsName);

    }
    objectsName = objectsName.substr(0, objectsName.length - 1);
    objectsId = objectsId.substr(0, objectsId.length - 1);
    handler += '{"projectId":"' + projectId + '","pbraName":"' + objectsName + '","pbraId":"'+ objectsId + '","category":"'+ punishWayId + '","alertId":"'+ rowId + '","description":"'+ remark + '","result":"'+punishMoney+'"},';
    console.log("处罚数据:"+handler);
    }
    handler = handler.substr(0, handler.length - 1);
    handler += "]";
    //2、将所选对象传给后台
    $.ajax({
    url:"warning/addhandle",
    type:"post",
    dataType:"json",
    data:{
    "handler":handler
    },
    success:function(data){
    if(data === true){
    $.messager.alert("温馨提示","已处理!");
    setSelected("dealState","05");
    /*$("#dealWin").window("close");*/
    }
    }
    });
    }

  • 相关阅读:
    Codeforces Round #649 (Div. 2) D. Ehab's Last Corollary
    Educational Codeforces Round 89 (Rated for Div. 2) E. Two Arrays
    Educational Codeforces Round 89 (Rated for Div. 2) D. Two Divisors
    Codeforces Round #647 (Div. 2) E. Johnny and Grandmaster
    Codeforces Round #647 (Div. 2) F. Johnny and Megan's Necklace
    Codeforces Round #648 (Div. 2) G. Secure Password
    Codeforces Round #646 (Div. 2) F. Rotating Substrings
    C++STL常见用法
    各类学习慕课(不定期更新
    高阶等差数列
  • 原文地址:https://www.cnblogs.com/yuner-angel/p/7998814.html
Copyright © 2011-2022 走看看