1
我一直运行到我为什么这不会打印JavaScript代码的错误..的JavaScript无法打印/阵列
有人可以一种证明阅读并告诉我什么,我做错了什么?
我会发布HTML,但我只是将脚本导入到.html文件中的html和样板中的这种动作。
// JavaScript Document
//var $ = function (id){
//return document.getElementById(id);
// hooty hoo
var money = [0,0,0,0,0,0,0,0,0];
var newEntry;
var out;
//1
var $ = function(id) {
return document.getElementById(id);
};
window.onload =function()
{
var button = document.getElementById("Calculate");
button.addEventListener("click", calc, false);
newEntry = document.getElementById("inputVal").value;
out = document.getElementById("output");
};
//2
var calc = function()
{
var result = 200 + (parseFloat(.09 * newEntry));
//result.mathfloor(result/100);
result.toFixed();
//var answer = parseInt(document.getElementById("inputVal").value);
if(result<0){
return;
}
if(result >= 200 && result<=299)
++money[0];
if(result >= 300 && result<=399)
++money[1];
if(result >= 400 && result<=499)
++money[2];
if(result >=500 && result<=599)
++money[3];
if(result >=600 && result<=699)
++money[4];
if(result >= 700 && result<=799)
++money[5];
if(result >= 800 && result<=899)
++money[6];
if(result >= 900 && result<=999)
++money[7];
if(result >= 1000)
++money[8];
Display();
document.getElementById("inputVal").value = "0";
//3
var Display = function(){
$("output").value = "gross salary pay/n"+
"$200-299/t" + money[0] + "0" +
"$300-399/t" + money[1] +"0" +
"$400-499/t" + money[2]+ "0" +
"$500-599/t" + money[3]+ "0" +
"$600-699/t" + money [4] + "0" +
"$700-799/t" +money[5] + "0" +
"$800-899/t" + money[6]+ "0" +
"$900-999/t" + money[7] +"0" +
"$1000+/t" + money[8]+ "0" ;
};
window.addEventListener("load",calc,false); \t \t \t
};
<html>
<head>
\t <meta charset="utf-8">
\t <title>Salary</title>
\t
<script src="ArraySalary.js"></script>
</head>
\t <form action = "#">
<p>Gross Sales :
<input id = "inputVal" type= "number">
<input id = "Calculate" type = "button" value="submit"></p>
<textarea name= "output"
rows = "15" cols = "19"> </textarea>
</form>
\t
</body>
</html>
为t这里有一个实际的错误说了什么,或者是一个错误,因为你不知道为什么它没有做你认为应该做的事情? –
我不明白为什么它不打印..像它的空白;我会张贴HTML也 – steven
你可以将它转换成jsfiddle或堆栈的片段? (点击第二列左边的第五个按钮, –