日期:2014-05-17  浏览次数:20682 次

为什么js执行后,提示undefined
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/frame" prefix="frame"%>
<html>
<head>
<title>登陆</title>
<link href="/css/login.css" rel="stylesheet" type="text/css" >
</head>
<body>
<table id="managetable" width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
<tr height="40%">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr height="30%">
<td width="30%">&nbsp;</td>
<td width="40%">
<table width="600" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="21%" height="30"><div align="right"><span class="styleText">用户名:</span></div></td>
                 <td width="79%" height="30"><input id="username" value="123" type="text" style="height:18px; width:130px; border:solid 1px #cadcb2; font-size:12px; color:#81b432;"></td>
</tr>
<tr>
<td width="21%" height="30"><div align="right"><span class="styleText">密码:</span></div></td>
                 <td width="79%" height="30"><input id="password" type="password" style="height:18px; width:130px; border:solid 1px #cadcb2; font-size:12px; color:#81b432;"></td>
</tr>
<tr>
<td></td>
<td><input id="btnLogin" type="button" value="登陆" onclick="login();"><input type="button" value="重置" onclick="reset();"></td>
</tr>
</table>
</td>
<td width="30%">&nbsp;</td>
</tr>
<tr height="30%">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
<script type="text/javascript">
function login(){
alert('登陆');
}
function reset(){
alert('1');
var a=document.getElementById("username").Value;
alert(a);

alert('3');
}
</script>
</html>
------解决方案--------------------
document.getElementById("username").Value;
改成
document.getElementById("username").value;