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('请求失败,请检查您的网络连接');
                }
            });
        }
  • 相关阅读:
    OCS 2007 R2单机测试虚拟环境的搭建(windows server 2008 R2 x64)
    Linq的概念解析
    WCF Data Service与net.tcp承载分析
    codeplex上20个有意思的WPF程序
    各种SmartPhone上的跨平台开源框架的总结
    新开发Apple Store上软件的实施步骤
    VSTO应用程序中加入键盘钩子
    绝非偶然 苹果iPhone领先5年背后的迷思 【推荐】
    Windows上安装Mac OS虚拟机
    Visual Studio 远程调试的步骤
  • 原文地址:https://www.cnblogs.com/yszr/p/11505299.html
Copyright © 2011-2022 走看看