I have read somewhere in stackoverflow that we will not get the value of checkbox which is display:none using javascript but I am getting the value of checkbox in servlet.
Below is my JSP code
<script type="text/javascript">
function hideData(){
document.getElementById("checkBoxTest").style.display="none";
}
</script>
<form action="DisplayServlet" method="get" >
<input type="checkbox" value="CheckboxTest" id ="checkBoxTest" name = "checkBoxTest" checked/>Test <br/>
<a href="#" onclick = "return hideData();">Click to hide check box </a> <br/>
<input type="submit" value="Submit" />
</form>
But I am getting values of checkbox even if I hide it. But somewhere in stackoverflow I read that visibility:hidden will give value whereas display:none will null values.
My servlet code where I am getting values.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String checkBoxValue = request.getParameter("checkBoxTest");
System.out.println("checkBoxValue ====== "+checkBoxValue);
}