1. 程式人生 > >jquery 捕獲input標籤

jquery 捕獲input標籤

1.
20.5.101.31_/root>cat viewesblog.html 
<head>
    <title>運維平臺</title>
    <link rel="stylesheet" type="text/css" href="/static/Css/Deploy/viewesb.css">
    <link rel="stylesheet" type="text/css" href="/static/Css/Public/header.css">
    <link rel="stylesheet" type="text/css" href="/static/Css/Public/menu.css">
</head>
<body>
    <include file="Public:header"/>
    <div class="content">
        <include file="Public:menu"/>
        <div class="con fl">
        <label class="condition">應用系統</label>
        <select name="application" class="monitor">
            </select>
            
            <label class="condition">全域性流水號</label><input type="text" name="esbserviceflowno" class="monitor01">
            
            <label class="condition">ESB內部流水號</label>
            <select name="esbflowno" class="monitor02">
            </select>
           
    
    <input type="submit" value="生成ESB日誌" class="publish">
    <input type="submit" value="檢視對應日誌" class="check">
        </div>
                    <table class="gridtable fr">
            <tr><th>訊息</th></tr>
        </table>
    </div>
</body>
<script type="text/javascript" src="/static/Js/jquery-2.2.2.min.js"></script>
<script type="text/javascript" src="/static/Js/Deploy/viewesb.js"></script>
<!script type="text/javascript" src="/static/Js/Public/menu.js"><!/script>
<script type="text/javascript" src="/static/Js/Public/ajax.js"></script>
</html>


2.

20.5.101.31_/root>cat viewesb.js
$(function(){
        var _env_select = $("select[name='application']");
        var _esbserviceflowno_select= $("input[name='esbserviceflowno']");
        var _esbflowno_select = $("select[name='esbflowno']");
        getTemp('6666');
        function getTemp(env){
        var data = {};
        var successfn = function(jdata){
            var _HTML = "";
        _env_select.html("");
        $.each(jdata,function(i,val){
        _HTML = _HTML + "<option value="+jdata[i][0]+">"+jdata[i][0]+"</option>";
        });
        _env_select.html(_HTML);
        };
        var errorfn = function(jdata){
            alert("資料返回出錯");
        };
        
        $.ajax({
            type: "get",
            data: data,
            url: "/api/getdeployapp",
            dataType: "json",
            success: function(d){
                successfn(d);
            },
            error: function(e){
                errorfn(e);
            }
        });
    };
    
    Transaction = function(){
        this.selectflow = function(){
            var data = {};
            data.env=_env_select.val();
            data.flowno = _esbserviceflowno_select.val();
                        console.log('bbbbbbbbbbbbbb');
                        console.log(_esbserviceflowno_select.val());
                        console.log('bbbbbbbbbbbbbb');
            var successfn = function(jdata){
                var _HTML = "";
                _esbflowno_select.html("");
                $.each(jdata,function(i,val){
                    _HTML = _HTML + "<option value="+jdata[i][0]+">"+jdata[i][0]+"</option>";
                });
                _esbflowno_select.html(_HTML);
            };
            var errorfn = function(jdata){
                alert("資料返回出錯");
            };
            
            $.ajax({
                type: "get",
                data: data,
                url: "/api/viewesbflowno",
                dataType: "json",
                success: function(d){
                    successfn(d);
                },
                error: function(e){
                    errorfn(e);
                }
            });
        };
        
    
            
      };
    var transactionGet1 = new Transaction();
    transactionGet1.selectflow();
    _esbserviceflowno_select.on('change',function(){
        transactionGet1.selectflow();
    })            
});