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

为啥 运行到这里时document.getElementById("indicator").style.display="bloc

2013-01-11 
为什么 运行到这里时document.getElementById(indicator).style.displayblock显示是缺少对象的 ??本

为什么 运行到这里时document.getElementById("indicator").style.display="block";显示是缺少对象的 ??
本帖最后由 showbo 于 2012-10-24 21:19:18 编辑

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC"-//W3C//DTC HTML 4.01 Transitional//EN">
<html>
<head>
          <script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
          <script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
          <script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
        
          <script language="javascript">
          function check1()
          {
               if(document.ThisForm.userName.value=="")
               {
                    alert("请输入用户名");
                    document.ThisForm.userName.focus();
                    return false;
               }
               if(document.ThisForm.userPw.value="")
               {
                alert("请输入密码");
                return false;
                }
                document.getElementById("indicator").style.display="block";
                loginService.login(document.ThisForm.userName.value,document.ThisForm.userPw.value,0,callback);
                }
                function callback(data)
                {
                     document.getElementById("indicator").style.display="none";
                 if(data=="no")
                {
                     alert("用户名或密码错误");
                }


                if(data=="yes")
                {
                     alert("通过验证,系统登录成功");
                     window.location.href="<%=path%>/loginSuccess.jsp";
                }
           }
           </script>
</head>
<body>
            <span>基于JSP的论坛网站</span></td>
            <FORM name="ThisForm" action="<%=path %>/adminLogin.action" method=post>
            <td>用户名:</td>
            <td><input name="userName" value=""></td>
            <td>密码:</td>
            <td><input name="userPw"></td>
            <input name="button" type="button" id="Submit" value="登录" onClick="check1()">
            <input name="cs" type="reset" id="cs" value="重置"></td>
            </body>
</html>


[解决办法]
你的html代码里面就没有id为indicator的对象啊。。加上,form标签也没闭合,td乱嵌套。

<body>
            <span>基于JSP的论坛网站</span></td>
            <FORM name="ThisForm" action="<%=path %>/adminLogin.action" method=post>
<table><tr>
            <td>用户名:</td>
            <td><input name="userName" value=""></td>
            <td>密码:</td>
            <td><input name="userPw"></td>
            <input name="button" type="button" id="Submit" value="登录" onClick="check1()">
            <input name="cs" type="reset" id="cs" value="重置"></td>
</tr></table>
<div id="indicator" style="display:none">提示内容。。。。。</div>
            </body>
[解决办法]
如果你的页面有id为:indicator的话,那一定能找得到,前提条件,你的html页面要规范。不要乱了。
[解决办法]
看标题以为你是用错了范围,结果看内容才晓得你的页面里面没有定义ID为indicator的节点吧。

热点排行