jquery取值赋值

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@include file="/common/common_css.jsp"%>
<%@include file="/common/common_js.jsp"%>
<title>开放平台监控系统</title>
</head>
<body>
    <%@include file="../../menu/header.jsp"%>
    <%@include file="../../menu/left.jsp"%>

    <div class="control">
        <div>
            <ul class="breadcrumb">
                <li style="font-size: large;"><a href="javascript:void(0)">异常监控策略列表</a>
                </li>
            </ul>
        </div>

        <div style="margin-top: 10px;">
            <button type="button" class="btn" id="newAppBtn" οnclick="showAdd()">新建监控策略</button>
        </div>
        <div id="create_area" style="display: none">

            <form class="form-horizontal" id="createForm">
                <fieldset>
                     <input type="hidden" id="ruleId" value="">
                    <div class="control-group">
                        <label class="control-label">主机ip</label>
                        <div class="controls">
                             <input type="text" id="hostIp" size="64" class="span5">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">异常类型</label>
                        <div class="controls">
                            <input type="text" id="exceptionType" size="64" class="span5">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">异常内容(模糊匹配)</label>
                        <div class="controls">
                            <input type="text" id="content" size="64" class="span5">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">时间间隔(分钟)</label>
                        <div class="controls">
                            <input type="text" id="timeLag" size="64" class="span5">
                        </div>
                    </div>
                    <div class="control-group">
                        <div class="controls">
                            <button type="button" class="btn" id="create" οnclick="add()">确定</button>
                            <button type="button" class="btn" id="cancel"
                                οnclick="cancelAdd()">取消</button>
                        </div>
                    </div>

                </fieldset>
            </form>

        </div>
        <div style="margin-top: 10px;">
            <table class="table table-bordered table-striped">
                <tr>
                    <th>主机ip</th>
                    <th>异常类型</th>
                    <th>异常内容</th>
                    <th>时间间隔</th>
                    <th>操作</th>
                </tr>
                <c:forEach var="result" items="${results}">
                    <tr id="${result.id}">
                    
                        <c:choose>
                               <c:when test="${result.hostIp == null }">
                                   <td>所有服务器</td>
                               </c:when>
                               <c:otherwise>
                                   <td id="ip">${result.hostIp}</td>
                               </c:otherwise>
                          </c:choose>
                          
                        <c:choose>
                               <c:when test="${result.exceptionType == null }">
                                   <td>所有异常</td>
                               </c:when>
                               <c:otherwise>
                                   <td id="extype">${result.exceptionType}</td>
                               </c:otherwise>
                          </c:choose>
                        
                        <c:choose>
                               <c:when test="${result.content == null }">
                                   <td>无</td>
                               </c:when>
                               <c:otherwise>
                                   <td id="con">${result.content}</td>
                               </c:otherwise>
                          </c:choose>
                          
                          <c:choose>
                               <c:when test="${result.timeLag == null }">
                                   <td>默认30分钟</td>
                               </c:when>
                               <c:otherwise>
                                   <td id="lag">${result.timeLag}</td>
                               </c:otherwise>
                          </c:choose>
                          
                        <td>
                             <a href="javascript:void(0);" οnclick="del('${result.id}')">删除</a>&nbsp;<a
                            href="javascript:void(0);" οnclick="update('${result.id}','${result.hostIp}','${result.exceptionType}','${result.content}','${result.timeLag}')">更新</a>

                        </td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>
</body>
<script type="text/javascript">
function update(id,hostIp,exceptionType,content,timeLag){
    
    showAdd();

//设置表单值   


    $('#ruleId').val(id);
    $('#hostIp').val(hostIp);
    $('#exceptionType').val(exceptionType) ;
    $('#content').val(content) ;
    $('#timeLag').val(timeLag)  ;
    
}


function del(key){
    $.post("/monitor/rules/remove",{id:key},function (data){
        if(data == 1){
            alert("删除成功");
            $('#'+key).remove();
        }else{
            alert("删除失败");
        }
    })
}

function showAdd(){
     $('#create_area').css('display','block');
}

function cancelAdd(){
    document.getElementById("createForm").reset();
    $('#create_area').css('display','none');
}
function add(){
    var id = $('#ruleId').val();
    var hostIp = $('#hostIp').val();
    var exceptionType = $('#exceptionType').val();
    var content = $('#content').val();
    var timeLag = $('#timeLag').val();
    
    var params = {id:id,hostIp:hostIp,exceptionType:exceptionType,content:content,timeLag:timeLag};
        
    $.post("/monitor/rules/update",params,function (data){
        if(data == 1){
            alert("添加成功");
            location.reload();
        }else{
            alert("添加失败");
        }
    })

}
</script>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值