springmvc 中 jsp页面中想弄个用户和管理员用单选框选择登录有不同的操作权限 10
在网上说用js,但onsubmit一直没用。请大神解惑,本人菜鸟一个。<%@pagecontentType="text/html;charset=UTF-8"langua...
在网上说用js,但onsubmit一直没用。请大神解惑,本人菜鸟一个。
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script src="js/jquery-3.1.1.js"></script>
<html>
<head>
<title>login</title>
<script type="text/javascript">
function check1() {
var form = document.getElementById('form1');
var radios = form.getElementsByName('dl');
var len = radios.length;
for (var i = 0; i < len; i++) {
if (radios[i].getAttribute("checked") == true) {
form.action = radios[i].value;
}
}
return true;
}
</script>
</head>
<body>
<form id="form1" name="form1" method='post' action="" onsubmit="return check1()">
登录帐号:<input type="text" value="" class="text2" name="userId" id="userId"/><br>
登录密码:<input type="password" value="" class="text2" name="password" id="password"/><br>
<input name="dl" type="radio" value="/MainController/tushu" checked="true"/>用户登录
<input name="dl" type="radio" value="/MainController/checkUser"/>管理员登录<br>
<input type="submit" value="登录"/>
<a href="/MainController/addac">注册 </a>
</form>
</body>
</html> 展开
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script src="js/jquery-3.1.1.js"></script>
<html>
<head>
<title>login</title>
<script type="text/javascript">
function check1() {
var form = document.getElementById('form1');
var radios = form.getElementsByName('dl');
var len = radios.length;
for (var i = 0; i < len; i++) {
if (radios[i].getAttribute("checked") == true) {
form.action = radios[i].value;
}
}
return true;
}
</script>
</head>
<body>
<form id="form1" name="form1" method='post' action="" onsubmit="return check1()">
登录帐号:<input type="text" value="" class="text2" name="userId" id="userId"/><br>
登录密码:<input type="password" value="" class="text2" name="password" id="password"/><br>
<input name="dl" type="radio" value="/MainController/tushu" checked="true"/>用户登录
<input name="dl" type="radio" value="/MainController/checkUser"/>管理员登录<br>
<input type="submit" value="登录"/>
<a href="/MainController/addac">注册 </a>
</form>
</body>
</html> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询