未捕获的ReferenceError:未定义文档

时间:2016-02-05 05:45:50

标签: javascript jquery

所以我有一个简单的应用程序来帮助糖尿病患者计算他们需要帮助调节血糖的一些不同的东西。在页面的底部,我想说明一些不同的东西作为快速概述。因此,当我尝试将碳水化合物拉到我的列表中时,它不起作用。我该怎么办?代码如下所示



<!DOCTYPE HTML>
<html lang="en-us">

<head>
  <meta charset="utf-8" name="Austin" content="HTML Code and Java Script">
  <title>Title</title>

  <script type="text/javascript">
    function doseToEat() {
      var carbs = parseFloat(document.getElementById("carbs").value);
      var insulin = parseFloat(document.getElementById("insulinUnitPer10Carbs").value);
      var dose = carbs / (insulin * 10)
      document.getElementById("dose").innerHTML = dose;
      documnet.getElementById("carbsOutput").innerHTML = carbs;
    }

    function correction() {
      var currentBS = parseFloat(document.getElementById("currentBS").value);
      var correction = (currentBS - 100) / 30
      document.getElementById("correction").innerHTML = correction;
      document.getElementById("currentBSOutput").innerHTML = currentBS;
    }
  </script>


</head>

<body>
  <h3>This Is to help calculate and track your blood sugar.</h3>
  <input type="number" id="currentBS">Please Enter your current Blood Sugar.
  <br>
  <button type="button" onclick="correction()">Calculate Correction</button>
  <br>
  <label>This is your correction.</label>
  <div id="correction"></div>
  <br>
  <input type="number" id="carbs">How many Carbs will you be eating?
  <br>
  <input type="number" id="insulinUnitPer10Carbs">How many Units of Insulin do you need per 10 carbs?
  <br>
  <button type="button" onclick="doseToEat()">Calculate</button>
  <br>
  <label>This Is How much Insulin you should dose</label>
  <div id="dose"></div>

  <output type="number" id="time">Time:</output>
  <br>
  <output type="number" id="Date">Date:</output>
  <br>Current Blood Sugar:
  <output type="number" id="currentBSOutput"></output>
  <br>Carbs:
  <output type="number" id="carbsOutput"></output>
  <br>
</body>

</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

您错过了拼写document,需要更改此

documnet.getElementById("carbsOutput").innerHTML = carbs;
^------^

document.getElementById("carbsOutput").innerHTML = carbs;