日期:2014-05-16  浏览次数:20365 次

form带的action与submit里的onclick事件
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ログイン</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<SCRIPT LANGUAGE="JavaScript">
function clearForm(){
  document.form1.userName.value="";
  document.form1.password.value="";
  return;
}
</script>

</head>

<body>
<form name="form1" action="servlet/setCookie" method="POST">

<table border="0">
<tr>
<td>
<img src="login/login_top_id.jpg" width="56" height="16">
</td>
<td>
<input type="text" name="id">
</td>
</tr>
<tr>
<td>
<img src="login/login_top_ps.jpg" width="56" height="16">
</td>
<td>
<input type="text" name="password">
</td>
</tr>
<tr>
<td>
<input type="submit" name="login" onClick="" value="登录">
</td>
<td>
<input type="submit" name="clearForm" onClick="clearForm();"
value="清除">
</td>[/color]
</tr>
<tr>
<td nowrap align="center">
</td>
<td nowrap align="left">
Cookie保存期間:
<input type="radio" name="radiobutton" value="-1"
onclick="setCookie('name','castel1',this.value)"
checked="checked">
保存しない
  <input type="radio" name="radiobutton" value="86400"
onclick="setCookie('name','castel1',this.value)"
checked="checked">
1日
<input type="radio" name="radiobutton" value="604800"
onclick="setCookie('name','castel7',this.value)">
1週間
<input type="radio" name="radiobutton" value="2592000"
onclick="setCookie('name','castel30',this.value)">
1ヶ月
<input type="radio" name="radiobutton" value="31536000"
onclick="setCookie('name', 'castel30', this.value);"
  >6ヶ月
</td>
</tr>


</table>
</form>
</html>


------解决方案--------------------
<input type="submit"/〉把TYPE换成button