Javascript 如何在servlet中获取父子复选框的值
我希望servlet中所有父项和相应子项复选框的值都存储到数据库中。如何在servlet中获取父子复选框的值Javascript 如何在servlet中获取父子复选框的值,javascript,html,Javascript,Html,我希望servlet中所有父项和相应子项复选框的值都存储到数据库中。如何在servlet中获取父子复选框的值 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <!-- <script type="text/
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
请帮忙。
我希望servlet中所有父项和相应子项复选框的值都存储到数据库中。如何在servlet中获取父子复选框的值
请帮忙
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
在此处插入标题
申请表
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
${rolelist.role}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
选定部门:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
${list1.dname}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
${list2.typeName}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
${list3.otypeName}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
您必须将表单的操作设置为要发布的url
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
然后,在服务器代码中,必须将该URL映射到Servlet(如果使用标记,可以在web.xml或Servlet本身中进行映射)。然后实现Servlet的doPost方法,并按其名称访问复选框:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>
request.getParameter('depp');
表单中的所有内容都将提交,并可以如上所示捕获。我知道。但我想要父项和它们各自的子项复选框值我不明白。。没有“父”和“子”,您只有一个带有参数的请求(所有参数都在同一级别)。如果您希望数据具有层次结构,则需要发送json或老式XML之类的内容,但随后您不发布表单,而是(通常)通过AJAX请求发送表单。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<!-- <script type="text/javascript">
$('input[type=checkbox]').click(function(){
// if is checked
if($(this).is(':checked')){
$(this).parents('li').each(function() {
$(this).children('input').prop('checked', true);
});
} else {
// uncheck all children
$(this).parent().find('li input[type=checkbox]').prop('checked', false);
}
</script> -->
<body>
<p>Application Form</p>
<div class="registration">
<form id="createForm" action="NewUserServlet" method="post">
<input type="text" placeholder="Email" name="email"
required="required" />
<input type="text" placeholder="password"
name="password" required="required" />
<input type="text"
placeholder="Name" name="name" /><br /><br />
<input type="text" placeholder="Mobile number" name="MobNo" />
<select name="role">
<c:forEach items="${RoleList}" var="rolelist">
<option value="${rolelist.roleId}">${rolelist.role}</option>
</c:forEach>
</select><br></br>
<h5>Select Departments:</h5>
<ul>
<c:forEach items="${DepList}" var="list1">
<li>
<input type="checkbox" value="${list1.did}" name="depp">${list1.dname}<br />
<ul>
<c:forEach items="${BkTypeList}" var="list2">
<li>
<input type="checkbox" value="${list2.typeId}" name="bkTypes">${list2.typeName}<br />
<ul>
<c:forEach items="${OpTypeList}" var="list3">
<li>
<input type="checkbox" value="${list3.otypeId}" name="oTypes">${list3.otypeName}<br />
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
<input type="submit" name="sub" value="Submit"/>
</form>
</body>
</html>