I want to try to get the value from a checkbox using JSP but so far with not success
<%!
// Define global variables
String state = "off";
%>
<%!
public void getState(String state) {
if(state.equals("on")){
%> <h1>ON</h1> <%!
}
}
%>
<!-- Toggle button -->
<div class="togglebutton">
<label>
<input type="checkbox" onclick="<% getState(state); %>">
<span class="toggle"></span>
Toggle is off
</label>
</div>
The thing with this code is that it print the function without being called! any help will be much appreciated!