gpt4 book ai didi

javascript - 我在下面的代码中做错了什么?

转载 作者:行者123 更新时间:2023-11-28 16:06:50 25 4
gpt4 key购买 nike

<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 输出控制台

最佳答案

你错过了很多东西:比如

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

此处缺少连接运算符

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 控制台的习惯,这样你就知道代码哪里出了问题。

关于javascript - 我在下面的代码中做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14556003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com