标题:javascript脚本不能正常执行
只看楼主
lgdcky
Rank: 2
等 级:论坛游民
威 望:5
帖 子:576
专家分:18
注 册:2006-8-5
结帖率:33.33%
 问题点数:0 回复次数:4 
javascript脚本不能正常执行
我写了一个jsp页面,前几次都可以正常运行可是这次突然无法正常执行了
firefox里的错误控制台报的是document.getElementById("userPassword") has no properties可是我找了半天也没有发现问题!错误是红字处的
谁能帮我看一下
代码如下:
<%@ page language="java" pageEncoding="gb2312"%>


<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><bean:message key="index.title" /></title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function validate_form(thisform) {
with(thisform) {
var userId = document.getElementById("userid").value;
var userPassword = document.getElementById("userPassword").value;
if (userId == null || userId == "") {
document.getElementById("userid").style.display = "block";
return false;
}
if (userPassword == null || userPassword == "") {
document.getElementById("passwordError").style.display = "block";
return false;
}
return true;
}
}
</script>
</head>

<body>
<table width="94%" height="459" border="0" cellspacing="0">
<tr>
<td height="43" align="center">
<table width="68%" border="0" cellpadding="0" cellspacing="0"
bgcolor="#CCCCCC">
<tr>
<td height="35" align="center" bgcolor="#0099FF"><bean:message
key="index.head" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="10" align="center">
<table width="90%" border="0" cellspacing="0">
<tr>
<td width="77%" height="21"><bean:message key="index.toRegedit" /><html:link
page="/view/reg.jsp">
<bean:message key="index.regedit" />
</html:link></td>
<td width="23%"><html:link page="/admin.jsp">
<bean:message key="index.toAdmin" />
</html:link></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="11" align="center">
<hr>
</td>
</tr>
<tr>
<td align="center" valign="middle"><html:form action="/Log.do"
focus="userid" onsubmit="return validate_form(this)">
<table width="41%" height="132" border="10" cellpadding="10"
cellspacing="0">
<tr bgcolor="#0099FF">
<td colspan="2">
<table width="90%" height="38" border="0" cellspacing="0">
<tr>
<td width="24%" align="center"><bean:message
key="index.userName" /></td>
<td width="76%"><html:text property="userid" size="13"
maxlength="15" />
<div id="userid" style="display:none"><bean:message
key="index.userIdNull" /></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<table width="90%" height="33" border="0" cellspacing="0">
<tr>
<td width="24%" align="center"><bean:message
key="index.password" /></td>
<td width="76%"><html:password property="userPassword" size="13"
maxlength="15" />
<div id="passwordError" style="display:none"><bean:message
key="index.userPassword" /></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="47%" align="center"><html:submit>
<bean:message key="index.submit" />
</html:submit></td>
<td width="53%" align="center"><html:reset>
<bean:message key="index.reset" />
</html:reset></td>
</tr>
</table>
</html:form> <html:errors /></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>

[此贴子已经被作者于2007-6-30 2:14:06编辑过]

搜索更多相关主题的帖子: 脚本 javascript 
2007-06-30 01:52
enlangs
Rank: 1
等 级:等待验证会员
威 望:2
帖 子:218
专家分:0
注 册:2007-5-28
得分:0 
你的userPassword表单呢?

[CODE]<td align="center" valign="middle"><html:form action="/Log.do"
focus="userid" onsubmit="return validate_form(this)">[/CODE]这儿给form加个值为userPassword的ID.
2007-06-30 09:12
lgdcky
Rank: 2
等 级:论坛游民
威 望:5
帖 子:576
专家分:18
注 册:2006-8-5
得分:0 

不明白什么意思!


2007-06-30 10:36
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 

没有那个域,如何赋值


可惜不是你,陪我到最后
2007-06-30 11:18
lgdcky
Rank: 2
等 级:论坛游民
威 望:5
帖 子:576
专家分:18
注 册:2006-8-5
得分:0 
可是我在标签中不是给了名字了吗!
<html:password property="userPassword" size="13" maxlength="15" />

2007-06-30 12:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-151488-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.525067 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved