一般的標簽如 <input type="botten">不具有把表單提交到servlet的功能碧囊;
如下面這段代碼
<form action="${pageContext.request.contextPath}/LoginServlet" method="post"
id="loginForm">
賬號:<input name="login_name" type="text"
class="width150" value="admin"/>
密碼:<input name="password" type="password"
class="width150" value="123"/>
驗證碼:<input name="checkcode" type="text"
class="width70" value="1111"/>
<img id="code" src="${pageContext.request.contextPath }/CheckCodeServlet"
alt="驗證碼" title="點擊更換" onclick="change()" />
<span class="required">${msg1 }</span>
<td class="login_button" colspan="2" id="login">
<a onclick="mySubmit()"><img src="jsp/images/login_btn.png" /></a>
<span class="required">${msg }</span>
</form>
這里的提交按鈕是一張圖片圆兵,沒有提交表單的功能
所以給a標簽一個動態(tài)操作的js功能的方法mySubmit()
并添加js代碼如下
<script type="text/javascript">
function mySubmit(){
var ms=document.getElementById("loginForm");
ms.submit();
}
</script>
其中獲取的id是form標簽的id······end
太容易得到的東西也總是很容易失去