zoukankan      html  css  js  c++  java
  • js笔记

     js搜索框,ajax提交后台,获取文本框的值


    <form id="query-ele"> <input type="text" placeholder=" 微信" style="200px" class="input-text selectinput" name="wei_xin"> <input type="text" placeholder=" 授权证书号" style="200px" class="input-text selectinput" name="certificate"> <button name="" id="" class="btn btn-success" type="button" onclick="chartreload()"> <i class="Hui-iconfont">&#xe665;</i> 搜索</button> <button name="" id="turnNull" class="btn btn-success" type="reset" onclick="tableClear()"> <i class="Hui-iconfont">&#xe6a6;</i> 清空</button> </form>
     function chartreload(){
            if(document.getElementById('query-ele')){
                elearr=document.getElementById('query-ele').getElementsByClassName('selectinput'); // 获取表单中有多少个要搜索的input元素
            }
            this.tjstr={}; // 循环元素个数,将所有表单中的元素挨个循环赋值给tjstr这个数组,
            for(var i=0; i<elearr.length; ++i){
                var name=elearr[i].name;
                this.tjstr[elearr[i].name]=$.trim(elearr[i].value);
            }
            //console.log(this.tjstr); // 此处打印的就是搜索表单的每个input值
            $.ajax({
                url:window.location.pathname,
                data:{tj:this.tjstr},
                type:'POST',
                dataType:"JSON",
                success:function(data){
                    if (data["status"]==1){
                        if (data["userInfo"].length != 0){
                            $userInfo=' <tr class="text-c">';
                            $userInfo+='<th defaultcls="" class="undefined" style=" 50px;">'+data["uid"]+'</th>';
                          
                            $userInfo+='<th defaultcls="" class="undefined" style=" 100px;">'+data["equityAll"]+'</th>';
                            $userInfo='</tr>';
                            $("#margin").html($userInfo);
                        }
                        if (data["userInfoHistory"].length != 0){
                            $teamDetail="";
                            for (var i=0;i<data["userInfoHistory"].length;i++ ){
                                $teamDetail+=' <tr class="text-c">';
                                $teamDetail+='<th defaultcls="" class="undefined" style=" 50px;">'+data["userInfoHistory"][i]["u_name"]+'</th>';
                          
                                $teamDetail='</tr>';
                            }
                            $("#detail").html($teamDetail);
                        }
                    }else{
                        layer.msg(data["msg"]);
                    }
                },
                error:function(data) {
                    layer.msg('请求失败,请检查您的网络连接');
                }
            });
        }
  • 相关阅读:
    递延收益
    企业收到政府补助的核算方法
    总额法
    发行股票手续费为什么冲减资本公积
    溢价发行
    融资筹资的区别是什么
    资本公积转增股本
    认股权证和股票期权有什么区别?
    postgresql 锁表查询语句
    生成不带版本的jar包 不影响deploy
  • 原文地址:https://www.cnblogs.com/yszr/p/11505299.html
Copyright © 2011-2022 走看看