using javascript in html i want to add names to a list and s
using javascript in html i want to add names to a list and store them in local storage. Then i want to collect those names and automatically add them to an options scroll bar so that the user can be able to select them for another use. Please provide the actual code step by step with comments
Solution
<!DOCTYPE>
<html>
<head>
<title> Local storage</title>
<style type=\"text/css\">
table#table1{
width: 10%;
background-color: #gray;
}
</style>
<script>
function saveMy(){
var fieldValue = document.getElementById(\'textfield\').value;
localStorage.setItem(\'text\', fieldValue);
}
function load(){
var storedValue = localStorage.getItem(\'text\');
if(storedValue){
document.getElementById(\'textfield2\').value = storedValue;
}
}
function removeMy() {
document.getElementById(\'textfield\').value = \'\';
localStorage.removeItem(\'text\');
}
</script>
</head>
<body onload=\"load()\">
<input type=\"text\" id=\"textfield\" />
<input type=\"button\" value=\"save\" onclick=\"saveMy()\"/>
<input type=\"button\" value=\"remove\" onclick=\"removeMy()\"/>
<hr/>
<table id=\"table1\" border=\"1\">
<tr>
<th>text</th>
</tr>
<tr>
<td>
<input type=\"text\" id=\"textfield2\" />
</td>
</tr>
</table>
</body>
</html>

