一只会飞的白菜 2017-09-09 14:55 采纳率: 0%
浏览 713
已结题

js 页面搜索取值,取不出来

 function doSearch(){
            var searchucard=document.getElementById("search").value;
            if(searchucard==""){
                alert("请输入身份证");
                return;
            }
            var nameLength=searchucard.length;
            var table = document.getElementById("dg");
            var rowsLength = table.row.length;
            console.log(rowsLength); 
            var resultTable=document.getElementById("dg");
            var resultLength=resultTable.row.length;
            console.log(resultLength); 
            while(resultLength>0){
                resultTable.deleteRow(resultLength-1);
                resultLength--;
            }
             for(i=0;i<rowsLength;i++){
             //根据姓名搜索
                 if(searchucard!=""){
                 //找到姓名那一列
                    var ucard=table.row[i].cells[1].innerText;
                    var cellsLength=table.row[i].cells.length;

                      alert(cellsLength);
                    if(searchucard==ucard.substring(0,nameLength)){
                        var currentRow=resultTable.row.length;
                        var NewRow=resultTable.insertRow(currentRow);
                        for(j=0;j<cellsLength;++j){
                            newCell=NewRow.insertCell(j);                   
                            newCell.innerText= table.row[i].cells[j].innerText;
                        }
                    }
                }
         } 
} 
 $(function(){
    $("#dg").edatagrid({
        pageList:[5,10,20],
        fitColumns :true,
        pageSize:5,
        url:'json.action',
        remoteSort: false,
        pagination:true,
        toolbar:'#toolbar',
        columns:[[
                  {field:'uid',title:'编号',width:80},
                  {field:'uname',title:'名字',width:80,editor:{type:'text',options: {required: true}}},
                  {field:'ucard',title:'身份证',width:80,editor:{type:'text',options: {required: true}}},
                  {field:'ugender',title:'性别',width:80,editor:{type:'text',options: {required: true}},sortable:true,formatter:function(value,index,row){
                      if(value==1){
                          return '男';
                      }else if(value==2){
                          return '女';
                      }
                  },
                  editor:{
                        type:'combobox',
                        options:{
                            valueField:'rstateid',
                            textField:'text',
                            url:'data',
                            panelHeight:'auto',
                            required:true,  
                            data:[{
                                 rstateid:1,
                                 text: '男'
                                 },{
                                rstateid: 2,
                                 text: '女',
                               }]
                        }}},
                  {field:'uphone',title:'电话',width:100,editor:{type:'text',options: {required: true}}},
                  {field:'ucount',title:'人住人数',width:100,editor:{type:'text',options: {required: true}}}
              ]]
    })
    var row = $('#dg').datagrid('reload');
}); 
  • 写回答

4条回答 默认 最新

  • 一只会飞的白菜 2017-09-10 00:45
    关注

    自己顶一下,不会,??????

    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧