问题描述
我有使用html的java脚本代码。
i希望每当我在浏览器中运行我的代码时,我希望浏览器显示之前的值而不是空白t填充值。
怎么做PLZ帮助。
提前预付款。
<!DOCTYPE html>
< html>
< head>
< title>生成预算< / title>
< / head>
< script type =text / javascript>
函数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(预测);
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());
}
documen t.getElementById(form2)。innerHTML = tableHtml;
}
函数generateBudget()
{var numOfYears = Math.abs(document.getElementById('end')。value -
document.getElementById('start' ).value);
localStorage.setItem(Math.abs(document.getElementById('end')。value -
文件.getElementById('start')。value),numOfYears);
var budget = Math.abs(document.getElementById('budget')。value);
localStorage.setItem(Math.abs(document.getElementById('budget')。value),预算)
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( | |
预算 | ); tableHtml = tableHtml.concat(budget / numOfYears); tableHtml = tableHtml。 concat( |
Forecast | ); tableHtml = tableHtml.concat(< input type ='text 'name ='代表+ 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();
document.getElementById(form)。innerHTML = tableHtml;
}
< / script>
Start Year | < input type =textname =startid =start/>
| < input type =textname =endid =end/> | ||
预算 | < input type =textname =预算id =预算/>
|
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("");
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" />
|
< textarea id = form2>
< / textarea>
< / body>
< / html>
这是代码
<textarea id="form2">
</textarea>
</body>
</html>
this is the code
推荐答案
这篇关于我运行代码后如何保留我的浏览器页面值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!