i have java script code using html.
i want that whenever i run my code in browser i want the browser to display the previous values and not blank t fill values again.
how to do plz help.
thanx in advance.
<!DOCTYPE html>
<html>
<head>
<title>Generate Budget</title>
</head>
<script type="text/javascript">
function tableprint()
{
var numOfYears = Math.abs(document.getElementById('end').value -
document.getElementById('start').value);
var budget = Math.abs(document.getElementById('budget').value);
var i = 0;
var tableHtml = "";
for (i=0; i<=numOfYears; i++)
{tableHtml = tableHtml.concat("(");
tableHtml = tableHtml.concat(Number(document.getElementById
('start').value)+Number(i));
tableHtml = tableHtml.concat(":");
tableHtml = tableHtml.concat("Budget");
tableHtml = tableHtml.concat(":");
tableHtml = tableHtml.concat(budget/numOfYears);
tableHtml = tableHtml.concat(";");
tableHtml = tableHtml.concat("Forecast");
tableHtml = tableHtml.concat(":");
tableHtml = tableHtml.concat(Number(document.getElementById('for'+i).value));
tableHtml = tableHtml.concat(";");
tableHtml = tableHtml.concat("Actual");
tableHtml = tableHtml.concat(":");
tableHtml = tableHtml.concat(Number(document.getElementById('act'+i).value));
tableHtml = tableHtml.concat(")");
}
document.getElementById("form2").innerHTML =tableHtml;
}
function generateBudget()
{ var numOfYears = Math.abs(document.getElementById('end').value -
document.getElementById('start').value);
localStorage.setItem("Math.abs(document.getElementById('end').value -
document.getElementById('start').value)", numOfYears);
var budget = Math.abs(document.getElementById('budget').value);
localStorage.setItem("Math.abs(document.getElementById('budget').value)",budget)
var i = 0;
if( numOfYears < 1)
{
numOfYears = 1;
}
var tableHtml = "";
tableHtml = tableHtml.concat("");
for (i=0; i<=numOfYears; i++)
{
tableHtml = tableHtml.concat("");
}
tableHtml = tableHtml.concat("");
tableHtml = tableHtml.concat("");
for (i=0; i<=numOfYears; i++)
{
tableHtml = tableHtml.concat("");
}
tableHtml = tableHtml.concat("");
tableHtml = tableHtml.concat("");
for (i=0; i<=numOfYears; i++)
{
tableHtml = tableHtml.concat("");
}
tableHtml = tableHtml.concat("");
tableHtml = tableHtml.concat("");
for (i=0; i<=numOfYears; i++)
{
tableHtml = tableHtml.concat("");
}
tableHtml = tableHtml.concat("
| ");
tableHtml = tableHtml.concat(Number(document.getElementById
('start').value)+Number(i));
tableHtml = tableHtml.concat(" |
Budget | ");
tableHtml = tableHtml.concat(budget/numOfYears);
tableHtml = tableHtml.concat(" |
Forecast | ");
tableHtml = tableHtml.concat("<input type='text' name='for" +Number(i)+"'
id='for" + Number(i) + "' />");
tableHtml = tableHtml.concat(" |
Actual | ");
tableHtml = tableHtml.concat("<input type='text' name='act" +Number(i)+"'
id='act" + Number(i) + "' />");
tableHtml = tableHtml.concat(" |
");
tableHtml = tableHtml.concat("
<input type='button' name='submit'
id='submit' value='Submit' />");
document.getElementById("form").innerHTML = tableHtml;
}
</script>
Start Year | <input type="text" name="start" id="start" />
| <input type="text" name="end" id="end" />
|
| | Budget | <input type="text" name="budget" id="budget" />
<input type="button" name="generate" id="generate" value="Generate"
/> |
|
<textarea id="form2">
</textarea>
</body>
</html>
this is the code