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或堆棧的片段? (點擊第二列左邊的第五個按鈕, –