Link to home
Start Free TrialLog in
Avatar of Pradip Shenolkar
Pradip ShenolkarFlag for India

asked on

How to retain checked checkboxes after submitting the form to same page in jsp ?

I have a form in JSP.
When I check any 3 checkboxes and submit the form I want the checked checkboxes to retain their state.
How to achieve this using javascript ?


<html>
<body>

<form action="">
<input type="checkbox" name="axes" value="Time">Time<br>
<input type="checkbox" name="axes" value="Product">Product<br> 
<input type="checkbox" name="axes" value="Location">Location<br> 
<input type="checkbox" name="axes" value="Sore">Store<br> 
<input type="submit" value="submit">
</form>

</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pradip Shenolkar

ASKER

It solved the problem but it would be more helpful to me from my project perspective if the solution is achieved using javascript.
When the client submits the form, he creates a new request. The Javascript values from the previous page are lost. To use Javascript, you would have to store the data somewhere. You could use cookies or use localStorage (HTML5). Look at
http://www.tutorialspoint.com/javascript/javascript_cookies.htm
http://www.thesitewizard.com/javascripts/cookies.shtml
http://www.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/     
https://robert.accettura.com/blog/2012/01/17/localstorage-with-cookie-fallback/