how to save in local storage? (html 5 new features)
i want to save file in local storage and post it under the table to be able to see it.. how can i do that?
HTML Code:
<html>
<head>
<title>Offline App(Traffic Enforcement)</title>
<link rel="stylesheet" type="text/css" title="Preferred" href="popAddVio.css" />
<script type="text.javascript">
function save() {
try {
var date = document.getElementById('textDate').value;
var plate = document.getElementById('textPlate').value;
var name = document.getElementById('textName').value;
var address = document.getElementById('textAddress').value;
localStorage.lDate = date;
localStorage.lPlate = plate;
localStorage.lName = name;
localStorage.lAddress = address;
} catch (e) {
alert("Error save");
}
}
function load() {
var storedValue = localStorage.lDate;
if (storedValue) {
document.getElementById('date').value = storedValue;
}
}
</script>
</head>
<body >
<header>
<h1>Add Violations</h1>
</header>
<div id="vioForm">
<form>
<table border="0" width="400" align="center">
<tr>
<td><label>Date:</label></td>
<td><input id="vioDate" type="date" name="textDate" value="2011-01-13"/></td>
</tr>
<tr>
<td><label>Plate #:</label></td>
<td><input id="vioPlate" type="text" name="textPlate"</td>
<tr>
<td><label>Driver's Name:</label></td>
<td><input id="vioName" type="text" name="textName" /></td>
</tr>
<tr>
<td><label>Address:</label></td>
<td><input id="vioAddress" type="text" name="textAddress"/></td>
</tr>
<tr>
<td><label>Violation:</label></td>
<td><select id="combo">
<option value="move"> Moving Violation </option>
<option value="park"> Parking Violation </option>
</select></td>
</tr>
</table>
</form>
</div>
<div>
<form id="buttons">
<input type="button" value="SAVE" onclick="save()" />
<input type="button" value="CLOSE" onclick="window.close()" />
</form>
</div>
</body>
</html>