首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

为什么查询按钮,按下去没反应的.JS有关问题?有答案_火速结贴

2012-05-21 
为什么查询按钮,按下去没反应的.JS问题?_有答案_火速结贴HTML code%@page importcom.basic.Business%

为什么查询按钮,按下去没反应的.JS问题?_有答案_火速结贴

HTML code
<%@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> 



[解决办法]
自己调试下啊,看看js执行了没,再看看提交到服务器端没。

[解决办法]
调试下
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();
}
是否执行了
[解决办法]
楼主把firefox浏览安装上吧,再下个firebug插件,调试 看程序报什么错
[解决办法]
单步调试
[解决办法]
探讨

1)用Chrome(已改为:document.getElementByID())调试:
说是方法未定义
Uncaught ReferenceError: oceanquery is not defined

2)这样子写:
document.getElementById("q_deptname").value=document.getElementById("q_deptname_s……

[解决办法]
可能是你代码没规范吧 <input type="button" name="query" value="查询" onclick="javascript:oceanquery();"/>
这样可以不
[解决办法]
11楼说的什么啊?不会改才要问啊!!

热点排行
Bad Request.