在以下代码中找不到计算错误 [英] Whats wrong in the following code for finding the calculation
本文介绍了在以下代码中找不到计算错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<script>
var f, quantity, rate, customertotal, salertotal, totalshare;
function calc (f)
{
quantity=parseInt(f.quantity.value);
rate=parseInt(f.rate.value);
customertotal=(quantity*rate);
salertotal=(customertotal*.80);
totalshare=(customertotal*.20);
f.customertotal.value=customertotal;
f.salertotal.value=salertotal;
f.totalshare.value=totalshare;
}
</script>
推荐答案
请参阅我对该问题的评论。它没有多大意义。
然而,无论你想达到什么目标,至少有一个错误的东西:第一行。你不应该在函数之外声明任何东西。
(另外,紧跟''=''之后的所有括号都是多余的,但这不是错误。)
我建议什么?也许,尝试获得一些关于编程的基本知识,而不是专门的JavaScript,阅读有关编程的一些信息。现在,看起来你似乎没有任何线索。
-SA
Please see my comment to the question. It does not really make sense.
However, there is at least one wrong thing, no matter what you wanted to achieve: the very first line. You should not declare anything outside of the function.
(Also, all brackets immediately following ''='' are totally redundant, but this is not a bug.)
What I would advise? Maybe, try to get some basic knowledge about programming, not specifically JavaScript, read about programming a bit. Right now, it looks like you have no clue.
—SA
这篇关于在以下代码中找不到计算错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文