0
<html>

<h1>MB calculator</h1>

<script type="text/javascript">

var level = "0"; var brawlpoints = "0"; var brawlenergy = "0"; var pointsmake = "0";

function setlv()
{
level = docuent.forms["form"]["lv"].value;
alert("level = " + level);
}

var maxen = 95+(lv*5);
var exptolv = 110+(lv*15);

function setbpbe()
{
brawlpoints = document.forms["form"]["bp"].value;
brawlenergy = document.forms["form"]["be"].value;
alert("points per brawl = " + brawlpoints + "; energy per brawl = " brawlenergy);
}

function pointsupdate()
{
pointsmake = document.forms["form"]["p2m"].value;
alert("you want to make " + pointsmake);
}

function calculate()
{
var math1 = pointsmake/brawlpoints + 1;
var math2 = brawlenergy*math1;
var math3 = maxen*1.75;
var math4 = math2/math3 + 1;

document.write("To achieve your goal it will take you " + math1 + " brawls, this will take you " + math2 + " energy, or " + math4 + " levels, assuming a 75% refill levels you.);
}

</script>

<form name="form">

level:
<input type="text" name="lv" value="0">
<br>
<input type="button" value="update level" onclick="setlv()"> 
<br>
points per brawl done:
<input type="text" name="bp" value="0">
<br>
energy per brawl done:
<input type="text name="be" value="0">
<br>
<input type="button" value="update brawl energy and points" onclick="setbpbe()">
<br>
how many points you want to make:
<input type="text" name="p2m" value="0">
<br>
<input type="button" value="set points you want to make" onclick="pointsupdate()">
</form>

<input type="button" value="calculate" onclick="calculate()">

<h1>LV calculator</h1>

</html>

我看了几次,我不知道我做错了什么......很抱歉发布了整个事情,但我什至无法真正缩小错误所在,我对照一个类似的代码检查了它让它工作正常,我找不到与我一致的名称以外的区别......按钮不起作用。谢谢你的帮助。

Javascript 输出控制台

Uncaught ReferenceError: calculate is not defined test.html:64
Uncaught ReferenceError: pointsupdate is not defined test.html:61
Uncaught ReferenceError: setbpbe is not defined test.html:56
Uncaught ReferenceError: setlv is not defined test.html

单击每个按钮时的javascript输出控制台

4

2 回答 2

3

你错过了很多东西:比如

// lv is not defined anywhere before using here
var maxen = 95+(lv*5);
var exptolv = 110+(lv*15);

此处缺少 concat 运算符

alert("points per brawl = " + brawlpoints + "; energy per brawl = " brawlenergy);

应该

alert("points per brawl = " + brawlpoints + "; energy per brawl = " + brawlenergy);

此处缺少结束语

document.write("To achieve your goal it will take you " + math1 + " brawls, this will take you " + math2 + " energy, or " + math4 + " levels, assuming a 75% refill levels you.);

应该

document.write("To achieve your goal it will take you " + math1 + " brawls, this will take you " + math2 + " energy, or " + math4 + " levels, assuming a 75% refill levels you.");

还有更多……养成使用javascript控制台的习惯,这样你就知道你的代码哪里出了问题……

于 2013-01-28T05:41:07.347 回答
1

存在一个拼写错误,而不是文档,您键入的是文档。可能是它导致错误。

于 2013-01-28T05:41:37.420 回答