Skip to content

Instantly share code, notes, and snippets.

View camilokawerin's full-sized avatar
🏠
Working from home

Camilo J. Kawerín camilokawerin

🏠
Working from home
View GitHub Profile
<script>
// test for localStorage support
if(('localStorage' in window) && window['localStorage'] !== null){
var f = document.getElementById('mainform');
// test with PHP if the form was sent (the submit button has the name "sent")
<?php if(isset($_POST['sent'])){?>
// get the HTML of the form and cache it in the property "state"
localStorage.setItem('state',f.innerHTML);