<from name="login" method="post" id="login">
<input type="button" value="登陆" onclick="login()">
<input type="button" value="注册" onclick="registor()">
</from>
function login()
{
document.getElementById("login").action="<%=request.getContextPath()%>/loginForm/loginAction.action";
document.getElementById("login").submit();
}
function registor()
{
document.getElementById("login").action="<%=request.getContextPath()%>/loginForm/registorAction.action";
document.getElementById("login").submit();
}
本文介绍了一种使用JavaScript动态改变表单提交行为的方法。通过修改表单的action属性并调用submit方法,可以实现根据不同按钮触发不同的后台处理逻辑。这种方法适用于登录和注册等场景。

被折叠的 条评论
为什么被折叠?



