• 循环遍历取不同层级元素的值,以及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");*/
    }
    }
    });
    }

  • 相关阅读:
    [科普]DNS相关的攻击介绍
    php过滤函数
    robots.txt 文件指南
    【转】mysql函数
    java入门篇17 -- JDBC编程
    java入门16 -- http编程
    java入门篇14 --- tcp/udp
    java入门篇13 -- 多线程
    java入门篇12 --- IO操作
    java入门篇11 --- 集合
  • 原文地址:https://www.cnblogs.com/yuner-angel/p/7998814.html
Copyright © 2020-2023  润新知