我在 HTML 中设计一个登录页面,对于我使用servlet类的数据库,如果用户名&密码是正确的然后我在html页面中调用home class id,但我不知道如何从servlet文件调用html id。我正在使用一个html文件,登录&主页逻辑在一个html文件中,所以我的问题是如何从servlet调用home类的html文件。
<!doctype html>
<html lang="en">
<head></head>
<style>
.header{width: 100%;background-color: #8B008B;color: #fff;padding: 30px 0px;font-size: 30px;}
.footer{position:fixed;bottom:0;width:100%;background-color:#8B008B;color:#fff;padding:10px 0;}
</style>
<link rel="stylesheet" type="text/css" href="bootstrap.css" media="all" />
<body>
<div class="header">
<div class="conainer">
<div class="pull-left text-left col-md-6">
Bakers & More
</div>
<div class="pull-right text-right col-md-6">
<a class="btn btn-primary" href="#" role="button">Logged in as</a>
<a class="btn btn-primary" href="#" role="button">Logout</a>
</div>
<div class="clearfix"></div>
</div>
</div>
<div id="login">
<div class="col-md-3"></div>
<div class="col-md-6" style="margin-top: 8%;border: 1px solid;background-color: #FFE4C4;padding:30px;">
<form class="form-horizontal" name="login_form" action="checkUser" method="post" >
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<button type="submit" class="btn btn-default" onclick="myFunction()">Sign in</button>
<br />
<div id="demo"></div>
</div>
<div class="col-sm-offset-2 col-sm-4">
<a href="#" role="button">Forgot Paswaord</a>
</div>
</div>
</form>
</div>
<div class="col-md-3"></div>
</div>
<div class="col-md-12" style="display:none;" id="home">
<div class="col-md-3" style="margin-top: 2%;border: 1px solid;padding:30px;">
<h3>Administrator</h3>
<select class="form-control">
<option>User Details</option>
<option>Create user</option>
<option>Show User</option>
<option>Update User</option>
<option>Delete User</option>
</select><br />
<select class="form-control">
<option>Shop Details</option>
<option>Device</option>
<option>Product</option>
<option>Special Iems</option>
<option>Order</option>
</select><br />
<select class="form-control">
<option>User Details</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select><br />
<select class="form-control">
<option>Shop Details</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="col-md-3"></div>
</div>
<div class="footer">
<div class="container text-center">
<div>Copyright. All Rights Reserved</div>
</div>
</div>
<script>
function myFunction() {
var x, text;
// Get the value of the input field with id="numb"
x = document.getElementById("inputEmail3").value;
// If x is Not a Number or less than one or greater than 10
if (isNaN(x) || x < 1 || x > 10) {
text = "Input not valid";
} else {
text = "Input OK";
}
document.getElementById("demo").innerHTML = text;
}
</script>
</body>
</html>