<%@page import="com.basic.Business"%>
<%@ page language="java" import="java.util.*"
import="com.basic.GeneralDAO" import="com.basic.db.SQLParameter"
import="com.basic.DB" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/system";
GeneralDAO gd = new GeneralDAO();
//
String sql_show = "";
String sql_fields = "";
String sql_tables = "";
String sql_condition = "";
String sql_order = "";
String editpath = "/system/attend/update.jsp";
String editpath1 = "/system/attend/query.jsp";
String listpath = "/system/attend/query.jsp";
String edittitle = "出勤";
String tablename = "attend";
sql_show = "";
//sql_fields= " tab_attend left inner join tab_course on tab_attend.cours=b.b right inner join c on a.a=c.c inner join d on a.a=d.d ";
//sql_fields= "select tab_attend.tableid,tab_attend.courseno,tab_course.coursename from tab_attend ,tab_course where tab_attend.courseno=tab_course.tableid right inner join c on a.a=c.c inner join d on a.a=d.d ";
sql_fields = " tab_attend.*, tab_department.tableid deptid ,tab_course.coursename, tab_student.tableid stuid ,tab_student.name stuname,tab_department.name deptname ,tab_class.name classname ,tab_class.grade ";
// sql_fields = " tab_attend.* ";
//sql_tables = "tab_attend ";
//sql_tables = "tab_attend inner join tab_course on tab_attend.courseno = tab_course.tableid inner join tab_student   on (tab_attend.stuid = tab_student.tableid) inner join tab_department on( tab_attend.deptid = tab_department.tableid) "; sql_tables = "tab_attend inner join tab_course on tab_attend.courseno = tab_course.tableid inner join tab_student   on (tab_attend.stuid = tab_student.tableid) inner join tab_department on( tab_attend.deptid = tab_department.tableid) inner join tab_class on( tab_attend.class= tab_class.tableid) ";
sql_condition = "tab_attend.tableid !=? ";
sql_order = " order by tab_attend.createtime desc";
sql_condition += sql_order; //查询条件声明
String q_deptname = "";
String q_classname = "";
String q_stuid = "";
String q_coursename = "";
String q_year = "";
String q_month= ""; //组成查询字符串
int totalrecord = 2;
try {
totalrecord = gd.getSize("*", null, null, "tab_attend");
} catch (Exception ex) {
System.out.println("查询SIZE出错:" + ex.toString());
}
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" hreflang="utf-8" href="/images/skin.css"
rel="Stylesheet" />
<title>出勤</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/js/cqjw.js" charset="utf-8"></script>
<script type="text/javascript">

function init() {
alert("11");
        document.all.q_deptname_show.value="<%out.println(q_deptname);%>";
            document.all.q_classname_show.value="<%out.println(q_classname);%>";
    document.all.q_stuid.value="<%out.println(q_stuid);%>";
            document.all.q_coursename_show.value="<%out.println(q_coursename);%>";
    document.all.q_year_show.value="<%out.println(q_year);%>";
    document.all.q_month_show.value="<%out.println(q_month);%>";
}
 alert("11"); 
function oceanquery() {
 document.all.q_deptname_.value=document.all.q_deptname_show.value;
    document.all.q_classname.value=document.all.q_classname_show.value;
    document.all.q_stuid.value=document.all.q_stuid_show.value;
    document.all.q_coursename.value=document.all.q_coursename_show.value;
    document.all.q_year.value=document.all.q_year_show.value;
    document.all.q_month.value=document.all.q_month_show.value;
    
    document.all.p.value="1";
    document.all.myform.submit();
}
function createmanual() { } function okok() {
if (document.all.chk) {
if (document.all.chk.length > 1) {
for ( var i = 0; i < document.all.chk.length; i++) {
document.all.chk[i].checked = false;
}
} else {
if (document.all.chk.checked) {
document.all.chk.checked = false;
}
}
}
}</script>
<style>
#layout {
width: 2000px;
margin: 0 auto;
text-align: center;
}span {
background-color: #F0FFFF;
align: middle;
color: #00ff00;
}#datagridtd>td {
backcolor: #F0FFFF;
align: middle;
color: #00ff00;
}
</style> </head>
<body>

<iframe id="myiframe" style="display: none" src=""></iframe>
<%out.println("<script>alert('11');</script>");%>
<form name="myform" style="display: none" action="<%out.println(listpath); %>>" method="post">
<input name="p" value="" />
<input name="q_deptname" value="" />
<input name="q_classname" value="" />
<input name="q_stuid" value="" />
<input name="q_year" value="" />
<input name="q_month" value="" />
<input name="q_coursename" value="" />
</form> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>

<td>
<table width="100%" style="background-color: #F7F8F9;">
<tr>
<td style="width: 790px; background-color: #F7F8F9;">
系别:
<input style="width: 80px" id="q_deptname_show" />
&nbsp; 班别:
<input style="width: 80px" id="q_classname_show" />
&nbsp; 学号:
<select id="q_stuid_show" style="width: 80px">
<option value='0'>
</option> </select>
科目:
<input style="width: 80px" id="q_coursename_show" />
&nbsp; 年份:
<input style="width: 30px" id="q_year_show" />
&nbsp; 月份:
<input style="width: 20px" id="q_month_show" />
&nbsp;
</td>
<td align="right">
<input type="button" value="查询"
onclick="oceanquery();" />

&nbsp;
<input type="button" value="清空" onclick="scandata()" />
&nbsp;
<input type="button" value="删除" onclick="" />
&nbsp; &nbsp; &nbsp;
</td>
</tr>
</table>
<div class="datagrid_div">
<table class="datagrid">
                         <tr>
<th>
时间
</th> <th>
系别
</th>
<th>
班别
</th>
<th>
年级
</th>
<th>
学号
</th>
<th>
姓名
</th>
<th>
课程
</th>
<th>
节次
</th>
<th>
备注
</th>
</tr>
<%
if (totalrecord > 0) {
ArrayList al = new ArrayList();
SQLParameter[] parameter = new SQLParameter[1];
parameter[0] = new SQLParameter(1, 99);
al = gd.findDatas(sql_fields, sql_condition, parameter,
sql_tables); for (int i = 0; i <= al.size() - 1; i++) {
HashMap h = new HashMap();
h = (HashMap) al.get(i); out.println("<tr>");
out.println("<td>" + h.get("CREATETIME") + " </td>");
out.println("<td>" + h.get("DEPTNAME") + " </td>");
out.println("<td>" + h.get("CLASSNAME") + " </td>");
out.println("<td>" + h.get("GRADE") + " </td>");
out.println("<td>" + h.get("STUID") + " </td>");
out.println("<td>" + h.get("STUNAME") + " </td>");
out.println("<td>" + h.get("COURSENAME") + " </td>");
out.println("<td>第" + h.get("PERIOD") + " 节 </td>");
int a;
out.println("<td>"
+ DB.toAttendType(a = Integer.parseInt(h
.get("REMARK").toString().trim()))
+ " </td>"); //out.println("<td tyle='width: 100px'><span style='cursor:hand'>"
//+ h.get("createtime") + " </span></td>");
out.println("</tr>");
} }
%>
</table>
</div>
</body></html>

解决方案 »

  1.   

    调试下
    function oceanquery() {
         document.all.q_deptname_.value=document.all.q_deptname_show.value;
                document.all.q_classname.value=document.all.q_classname_show.value;
                document.all.q_stuid.value=document.all.q_stuid_show.value;
                document.all.q_coursename.value=document.all.q_coursename_show.value;
                document.all.q_year.value=document.all.q_year_show.value;
                document.all.q_month.value=document.all.q_month_show.value;
                
                document.all.p.value="1";
                document.all.myform.submit();
        }
    是否执行了
      

  2.   

    楼主把firefox浏览安装上吧,再下个firebug插件,调试 看程序报什么错
      

  3.   

    1)用Chrome(已改为:document.getElementByID())调试:
    说是方法未定义
    Uncaught ReferenceError: oceanquery is not defined2)这样子写:
     document.getElementById("q_deptname").value=document.getElementById("q_deptname_show").value;
    错误提示
    query.jsp:133Uncaught TypeError: Cannot set property 'value' of null
    明明是有这个属性的呀
      

  4.   

    红色字体为改动过的代码. 确定按钮的JS代码就可以执行到,不知道为什么?
    <%@page import="com.basic.Business"%>
    <%@ page language="java" import="java.util.*"
    import="com.basic.GeneralDAO" import="com.basic.db.SQLParameter"
    import="com.basic.DB" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
    + request.getServerName() + ":" + request.getServerPort()
    + path + "/system";
    GeneralDAO gd = new GeneralDAO();
    //
    String sql_show = "";
    String sql_fields = "";
    String sql_tables = "";
    String sql_condition = "";
    String sql_order = "";
    String editpath = "/system/attend/update.jsp";
    String editpath1 = "/system/attend/query.jsp";
    String listpath = "/system/attend/query.jsp";
    String edittitle = "出勤";
    String tablename = "attend";
    sql_show = "";
    //sql_fields= " tab_attend left inner join tab_course on tab_attend.cours=b.b right inner join c on a.a=c.c inner join d on a.a=d.d ";
    //sql_fields= "select tab_attend.tableid,tab_attend.courseno,tab_course.coursename from tab_attend ,tab_course where tab_attend.courseno=tab_course.tableid right inner join c on a.a=c.c inner join d on a.a=d.d ";
    sql_fields = " tab_attend.*, tab_department.tableid deptid ,tab_course.coursename, tab_student.tableid stuid ,tab_student.name stuname,tab_department.name deptname ,tab_class.name classname ,tab_class.grade ";
    // sql_fields = " tab_attend.* ";
    //sql_tables = "tab_attend ";
    //sql_tables = "tab_attend inner join tab_course on tab_attend.courseno = tab_course.tableid inner join tab_student   on (tab_attend.stuid = tab_student.tableid) inner join tab_department on( tab_attend.deptid = tab_department.tableid) "; sql_tables = "tab_attend inner join tab_course on tab_attend.courseno = tab_course.tableid inner join tab_student   on (tab_attend.stuid = tab_student.tableid) inner join tab_department on( tab_attend.deptid = tab_department.tableid) inner join tab_class on( tab_attend.class= tab_class.tableid) ";
    sql_condition = "tab_attend.tableid !=? ";
    sql_order = " order by tab_attend.createtime desc";
    sql_condition += sql_order; //查询条件声明
    String q_deptname = "";
    String q_classname = "";
    String q_stuid = "";
    String q_coursename = "";
    String q_year = "";
    String q_month= ""; //组成查询字符串
    int totalrecord = 2;
    try {
    totalrecord = gd.getSize("*", null, null, "tab_attend");
    } catch (Exception ex) {
    System.out.println("查询SIZE出错:" + ex.toString());
    }
    %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link type="text/css" hreflang="utf-8" href="/images/skin.css"
    rel="Stylesheet" />
    <title>出勤</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script language='javascript' src="/js/cqjw.js" charset="utf-8"></script>
    <script language='javascript'>
    function init() {
    if(document.all){
                document.all.q_deptname.value="<%out.println(q_deptname);%>";
                document.all.q_classname.value="<%out.println(q_classname);%>";
        document.all.q_stuid.value="<%out.println(q_stuid);%>";
                document.all.q_coursename_show.value="<%out.println(q_coursename);%>";
        document.all.q_year.value="<%out.println(q_year);%>";
        document.all.q_month.value="<%out.println(q_month);%>";
        
            document.all.q_deptname_show.value="<%out.println(q_deptname);%>";
                document.all.q_classname_show.value="<%out.println(q_classname);%>";
        document.all.q_stuid_show.value="<%out.println(q_stuid);%>";
                document.all.q_coursename_show.value="<%out.println(q_coursename);%>";
        document.all.q_year_show.value="<%out.println(q_year);%>";
        document.all.q_month_show.value="<%out.println(q_month);%>";
        }
    else{
       alert("既然不是IE,就是自己人,什么都好说");
        document.getElementById("q_deptname").value="<%out.println(q_deptname);%>"; 
        document.getElementById("q_classname").value="<%out.println(q_classname);%>"; 
        document.getElementById("q_stuid").value="<%out.println(q_stuid);%>"; 
        document.getElementById("q_coursename").value="<%out.println(q_coursename);%>"; 
        document.getElementById("q_year").value="<%out.println(q_year);%>"; 
        document.getElementById("q_month").value="<%out.println(q_month);%>"; 
        
        ocument.getElementById("q_deptname_show").value="<%out.println(q_deptname);%>"; 
        document.getElementById("q_classname_show").value="<%out.println(q_classname);%>"; 
        document.getElementById("q_stuid_show").value="<%out.println(q_stuid);%>"; 
        document.getElementById("q_coursename_show").value="<%out.println(q_coursename);%>"; 
        document.getElementById("q_year_show").value="<%out.println(q_year);%>"; 
        document.getElementById("q_month_show").value="<%out.println(q_month);%>"; 
       } }
    function oceanquery() {

    if(document.all){
        
     document.all.q_deptname.value=document.all.q_deptname_show.value;
        document.all.q_classname.value=document.all.q_classname_show.value;
        document.all.q_stuid.value=document.all.q_stuid_show.value;
        document.all.q_coursename.value=document.all.q_coursename_show.value;
        document.all.q_year.value=document.all.q_year_show.value;
        document.all.q_month.value=document.all.q_month_show.value;
        document.all.p.value="1";
        document.all.myform.submit();
       }
       else{
       alert("既然不是IE,就是自己人,什么都好说");
        document.getElementById("q_deptname").value=document.getElementById("q_deptname_show").value;
        document.getElementById("q_classname").value=document.getElementById("q_classname_show").value;
        document.getElementById("q_stuid").value=document.getElementById("uid_show.value").value;
        document.getElementById("q_coursename").value=document.getElementById("q_coursename_show").value;
        document.getElementById("q_year").value=document.getElementById("q_year_show").value;
        document.getElementById("q_month").value=document.getElementById("q_month_show").value;
        
        document.getElementById("myform").submit();
       }


    }

    </script><script language='javascript'>
      function show(){
       if(document.all){
        alert("姓名不能为空!");
        document.all.q_deptname.value=document.all.q_deptname_show.value;
        document.all.q_classname.value=document.all.q_classname_show.value;
        document.all.q_stuid.value=document.all.q_stuid_show.value;
        document.all.q_coursename.value=document.all.q_coursename_show.value;
        document.all.q_year.value=document.all.q_year_show.value;
        document.all.q_month.value=document.all.q_month_show.value;
        
        document.all.myform.submit();
       }
       else{
       alert("既然不是IE,就是自己人,什么都好说");
                document.getElementById("q_deptname").value=document.getElementById("q_deptname_show").value;
        document.getElementById("q_classname").value=document.getElementById("q_classname_show").value;
        document.getElementById("q_stuid").value=document.getElementById("uid_show.value").value;
        document.getElementById("q_coursename").value=document.getElementById("q_coursename_show").value;
        document.getElementById("q_year").value=document.getElementById("q_year_show").value;
        document.getElementById("q_month").value=document.getElementById("q_month_show").value;
        
       }
       }
     </script>
    <style>
    #layout {
    width: 2000px;
    margin: 0 auto;
    text-align: center;
    }span {
    background-color: #F0FFFF;
    align: middle;
    color: #00ff00;
    }#datagridtd>td {
    backcolor: #F0FFFF;
    align: middle;
    color: #00ff00;
    }
    </style> </head>
    <body>

    <iframe id="myiframe" style="display: none" src=""></iframe>
    <%out.println("<script>alert('11');</script>");%>
    <form name="myform" style="display: none" action="<%out.println(listpath); %>>" method="post">
    <input name="q_deptname" value="" />
    <input name="q_classname" value="" />
    <input name="q_stuid" value="" />
    <input name="q_year" value="" />
    <input name="q_month" value="" />
    <input name="q_coursename" value="" />
    </form> <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>

    <td>
    <table width="100%" style="background-color: #F7F8F9;">
    <tr>
    <td style="width: 790px; background-color: #F7F8F9;">
    系别:
    <input type="text" style="width: 80px" id="q_deptname_show" />
    &nbsp; 班别:
    <input type="text" style="width: 80px" id="q_classname_show" />
    &nbsp; 学号:
    <!-- 
    <select id="q_stuid_show" style="width: 80px">
    <option value='0'>
    </option> </select>
     -->
    <input  type="text" style="width: 80px" id="q_stuid_show" />
    科目:
    <input  type="text" style="width: 80px" id="q_coursename_show" />
    &nbsp; 年份:
    <input type="text" style="width: 30px" id="q_year_show" />
    &nbsp; 月份:
    <input type="text" style="width: 20px" id="q_month_show" />
    &nbsp;
    </td>
    <td align="right">
    <!-- <input type="button" name=query value='查询'  onclick="javascript:oceanquery();"/> -->
    <input type=button name=query value='查询' onclick="javascript:oceanquery();"/>
    <input type=button name=smt value='确定' onclick="javascript:show();"/>
    &nbsp;
    <input type="button" value="清空" onclick="scandata()" />
    &nbsp;
    <input type="button" value="删除" onclick="scandata()"/>
    &nbsp; &nbsp; &nbsp;
    </td>
    </tr>
    </table> </body></html>
      

  5.   

    (CSDN的,加了红,没效果,ctrl+c [color=#FF0000] ctrl+v ,找一个这个,就知道改了哪里)
      

  6.   

    可能是你代码没规范吧   <input type="button" name="query" value="查询" onclick="javascript:oceanquery();"/>
    这样可以不