0
嗨我有這個JavaScript表,我想知道是否有人可以幫助解釋如何添加小數點(2)。任何幫助都感激不盡。如何將小數點添加到Javascript行,Cols。 Vars
//Total Expenditure - Total
document.write ('<tr align="center"><td>' + row14col1var + '<\/td><td>' + row14col2var + '<\/td><td>' + row14col3var + '<\/td><td>' + row14col4var + '<\/td><td>' + row14col5var + '<\/td><td>' + row14col6var + '<\/td><td>' + row14col7var + '<\/td><td>' + row14col8var +'<\/td><td>' + row14col9var + '<\/td><td>' + row14col10var + '<\/td><td>' + row14col11var + '<\/td><td>' + row14col12var + '<\/td><td>' + row14col13var + '<\/td><td>' + row14col14var +'<\/td><\/tr>');
var row14col1var = '<b>Total Expenditure</b>';
var row14col2var = (Number(row4col2var) + Number(row5col2var) + Number(row6col2var)+ Number(row7col2var)+ Number(row10col2var)+ Number(row11col2var)+ Number(row13col2var));
var row14col3var = (Number(row4col3var) + Number(row5col3var) + Number(row6col3var) + Number(row7col3var)+ Number(row10col3var)+ Number(row11col3var)+ Number(row13col3var));
var row14col4var = (Number(row4col4var) + Number(row5col4var) + Number(row6col4var)+ Number(row7col4var)+ Number(row10col4var)+ Number(row11col4var)+ Number(row13col4var));
var row14col5var = (Number(row4col5var) + Number(row5col5var) + Number(row6col5var)+ Number(row7col5var)+ Number(row10col5var)+ Number(row11col5var)+ Number(row13col5var));
var row14col6var = (Number(row4col6var) + Number(row5col6var) + Number(row6col6var)+ Number(row7col6var)+ Number(row10col6var)+ Number(row11col6var)+ Number(row13col6var));
var row14col7var = (Number(row4col7var) + Number(row5col7var) + Number(row6col7var)+ Number(row7col7var)+ Number(row10col7var)+ Number(row11col7var)+ Number(row13col7var));
var row14col8var = (Number(row4col8var) + Number(row5col8var) + Number(row6col8var)+ Number(row7col8var)+ Number(row10col8var)+ Number(row11col8var)+ Number(row13col8var));
var row14col9var = (Number(row4col9var) + Number(row5col9var) + Number(row6col9var)+ Number(row7col9var)+ Number(row10col9var)+ Number(row11col9var)+ Number(row13col9var));
var row14col10var = (Number(row4col10var) + Number(row5col10var) + Number(row6col10var)+ Number(row7col10var)+ Number(row10col10var)+ Number(row11col10var)+ Number(row13col10var));
var row14col11var = (Number(row4col11var) + Number(row5col11var) + Number(row6col11var)+ Number(row7col11var)+ Number(row10col11var)+ Number(row11col11var)+ Number(row13col11var));
var row14col12var = (Number(row4col12var) + Number(row5col12var) + Number(row6col12var)+ Number(row7col12var)+ Number(row10col12var)+ Number(row11col12var)+ Number(row13col12var));
var row14col13var = (Number(row4col13var) + Number(row5col13var) + Number(row6col13var)+ Number(row7col13var)+ Number(row10col13var)+ Number(row11col13var)+ Number(row13col13var));
var row14col14var = (Number(row4col14var) + Number(row5col14var) + Number(row6col14var)+ Number(row7col14var)+ Number(row10col14var)+ Number(row11col14var)+ Number(row13col14var));
如果你重複做,你這樣做是錯誤的。這就是電腦的用途。您可能想要使用數組和循環的組合來存儲數據,而無需全部寫出。 – 2013-02-25 16:59:20