<from name="login" method="post" id="login">
<input type="button" value="登陆" onclick="login()">
<input type="button" value="注册" onclick="registor()">
</from>
function login()<br>{<br>document.getElementById("login").action="<%=request.getContextPath()%>/loginForm/loginAction.action";<br>document.getElementById("login").submit();<br>}<br>function registor()<br>{
document.getElementById("login").action="<%=request.getContextPath()%>/loginForm/registorAction.action";<br>document.getElementById("login").submit();<br>}
<input type="button" value="登陆" onclick="login()">
<input type="button" value="注册" onclick="registor()">
</from>
function login()<br>{<br>document.getElementById("login").action="<%=request.getContextPath()%>/loginForm/loginAction.action";<br>document.getElementById("login").submit();<br>}<br>function registor()<br>{
document.getElementById("login").action="<%=request.getContextPath()%>/loginForm/registorAction.action";<br>document.getElementById("login").submit();<br>}

本文介绍了一种使用JavaScript处理HTML表单中登录和注册按钮点击事件的方法。通过为按钮设置onclick属性来调用相应的函数,实现动态改变表单提交路径的功能。此方法适用于前端开发中需要区分不同用户操作的情况。

2305

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



