javascript - document.getElementById 取不到值!空白页测试可以
<!-- 工单管理 我的工单 -->
<%@ page language="java" import="java.util.*,com.qdzq.zqbp.entity.*,com.qdzq.zzpt.vo.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//Page<sys_role> p = (Page<sys_role>)request.getAttribute("page");
Page<zqbp_gdgl> p = (Page<zqbp_gdgl>) request.getAttribute("page");
String user = (String)session.getAttribute("user");
%>
<script language="javascript" type="text/javascript">
//转换器,将列的字段类型转换为可以排序的类型:String,int,float
function convert(sValue, sDataType) { //(值,类型(int ,date ,float,String))
switch(sDataType) { //选择类型
case "int":
return parseInt(sValue); //返回int型
case "float":
return parseFloat(sValue); //返回float型
case "date":
return new Date(Date.parse(sValue)); //返回date型(日期)
default:
return sValue.toString(); //转换为字符串
}
}
//排序函数产生器,iCol表示列索引,sDataType表示该列的数据类型
function generateCompareTRs(iCol, sDataType) { //类型索引,类型
return function compareTRs(oTR1, oTR2) {
var vValue1 = convert(oTR1.cells[iCol].firstChild.nodeValue, sDataType);
var vValue2 = convert(oTR2.cells[iCol].firstChild.nodeValue, sDataType);
if (vValue1 > vValue2) {
return -1;
} else if (vValue1 < vValue2) {
return 1;
} else {
return 0;
}
};
}
//排序方法
function sortTable(sTableID, iCol, sDataType) {
var oTable =document.getElementById(sTableID);
alert(oTable);//就是这里!!!!!!!!!!!!!!!!!!!!!!!!弹出null
if(oTable.rows.length<2){
alert("无数据");
return false;
}
var oTBody = oTable.tBodies[0];
var colDataRows = oTBody.rows;
var aTRs = new Array;
//将所有列放入数组
for (var i=0; i < colDataRows.length; i++) {
aTRs[i] = colDataRows[i];
}
//判断最后一次排序的列是否与现在要进行排序的列相同,是的话,直接使用reverse()逆序
if (oTable.sortCol == iCol) {
aTRs.reverse();
} else {
//使用数组的sort方法,传进排序函数
aTRs.sort(generateCompareTRs(iCol, sDataType));
}
var oFragment = document.createDocumentFragment();
for (var i=0; i < aTRs.length; i++) {
oFragment.appendChild(aTRs[i]);
}
oTBody.appendChild(oFragment);
//记录最后一次排序的列索引
oTable.sortCol = iCol;
}
</script>
<p class="pageHeader">
<form id="pagerForm" onsubmit="return navTabSearch(this);"
action="<%=basePath %>admin/gdgl/index1.html?name=<%=user%>" method="post">
<p class="searchBar">
<table class="searchContent">
<tr>
<td>
客户
</td>
<td >
<input type="text" class="floatLeft" value="" name="id" maxlength="50"/>
</td>
<td><p class="subBar">
<ul>
<li><p class="buttonActive"><p class="buttonContent"><button type="submit">检索</button></p></p></li>
</ul>
</p></td>
</tr>
</table>
</p>
<input type="hidden" name="page" value="<%=p.getPage()%>" /><!--【必须】value=1可以写死-->
<input type="hidden" name="rows" value="<%=p.getRows() %>" />
</form>
</p>
<p class="pageContent">
<p class="panelBar">
<ul class="toolBar">
<li><a class="add" href="<%=basePath %>admin/gdgl/add1.html"
target="navTab" ><span>新增</span>
</a>
</li>
<li>
<a class="edit" href="<%=basePath %>admin/gdgl/edit01.html?id={field_id}"
target="navTab"
warn="请选择数据"><span>编辑</span>
</a>
</li>
</ul>
</p>
<table class="table" width="1100" layoutH="108" rel="custom" id="tblSort">
<thead>
<tr>
<th width="100" onClick="sortTable('tblSort',0,'int')" >工单号</th>
<th width="100">客户</th>
<th width="70">时间</th>
<th width="100">问题描述</th>
<th width="75">附件</th>
<th width="75">维护时间</th>
<th width="75">状态</th>
</tr>
</thead>
<tbody>
<%
for (zqbp_gdgl one : p.getList()) {
%>
<tr target="field_id" rel="<%=one.getId()%>">
<td><%=one.getGdNum() == null ? "" : one.getGdNum() %></td>
<td><%=one.getGdCreateUser() == null ? "" : one.getGdCreateUser()%></td>
<td><%=one.getGdCreateTime() == null ? "" : one.getGdCreateTime() %></td>
<td><%=one.getGdContent() == null ? "" : one.getGdContent() %></td>
<td><%=one.getGdFjFilename() == null ? "" : one.getGdFjFilename() %></td>
<td><%=one.getGdDate() == null ? "" : one.getGdDate() %></td>
<%
if(one.getGdStatus()==0) {
%>
<td>未提交</td>
<%
}
%>
<%
if(one.getGdStatus()==1) {
%>
<td>已提交</td>
<%
}
%>
<%
if(one.getGdStatus()==2) {
%>
<td>已处理</td>
<%
}
%>
</tr>
<%
}
%>
</tbody>
</table>
<p class="panelBar">
<p class="pages">
<span>显示</span>
<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
<option value="20">20</option>
</select>
<span>条,共<%=p.getTotalCount() %>条</span>
</p>
<!--分页组件-->
<p class="pagination" targetType="navTab" totalCount="<%=p.getTotalCount()%>" numPerPage="<%=p.getRows() %>" pageNumShown="<%=p.getPageCount()%>" currentPage="<%=p.getPage()%>"></p>
</p>
</p>