我正在尝试创建一个包含两个框的表格,在其中键入高度和三角形的底数,然后可以在底部获得生成的区域,这是我到目前为止对其他形状的了解。但是我无法弄清楚三角形。我是新来的,所以对不起。

    <h3>Calculo de Areas</h3>
        <p>Ingrese la Informacion requerida para sacar el Area de las siguientes Figuras.</p>
        <p>Nota:Los Resultados estan dados en la misma unidad que se introduce.</p>
            <table>
        <tr>
            <th>
<p>
  <label>Radio de un Circulo</label>
  <input id="inputradio" type="number" placeholder="Radio" oninput="LengthConverter9(this.value)" onchange="LengthConverter9(this.value)">
</p>
<p>Area: <span id="outputArea"></span></p>

<script>
function LengthConverter9(valNum9) {
  document.getElementById("outputArea").innerHTML=(valNum9*valNum9)*3.14159265359;
}
                </script>
            </th><th>
<p>
  <label>Lado de un Cuadrado</label>
  <input id="inputLado" type="number" placeholder="Largo" oninput="LengthConverter10(this.value)" onchange="LengthConverter10(this.value)">
</p>
<p>Area: <span id="outputArea1"></span></p>

<script>
function LengthConverter10(valNum10) {
  document.getElementById("outputArea1").innerHTML=(valNum10*valNum10);
}
</script>

    <tr><th>
        <p>
  <label>Base de un Triangulo Rectangulo</label>
  <input id="inputBase" type="number" placeholder="Ancho" oninput="LengthConverter11(this.value)" onchange="LengthConverter11(this.value)">
</p>
        <p>
  <label>Altura de dicho Triangulo</label>
  <input id="inputAltura" type="number" placeholder="Alto" oninput="LengthConverter12(this.value)" onchange="LengthConverter12(this.value)">
</p>
<p>Area: <span id="outputArea4"></span></p>
<script>
function LengthConverter11(valNum11){
  document.getElementById("outputMetros4").innerHTML=(LengthConverter11*LengthConverter12)/2;
}
                </script>


        </th></tr>
    </table>


我不能上班的唯一一个就是三角形三角形,谢谢。

最佳答案

看着这个

  <input id="inputAltura" type="number" placeholder="Alto" oninput="LengthConverter12(this.value)" onchange="LengthConverter12(this.value)">


您尚未为LengthConverter12定义任何功能

看着这个(三角形的计算面积)

document.getElementById("outputMetros4").innerHTML=(LengthConverter11*LengthConverter12)/2;


您正在将一个未定义函数定义的函数乘以吗?

我建议您将所有js代码放在一个部分中,这样就很容易调试和阅读。但是,使用您的布局并根据现有内容进行构建,以下是以下代码段



<h3>Calculo de Areas</h3>
<p>Ingrese la Informacion requerida para sacar el Area de las siguientes Figuras.</p>
<p>Nota:Los Resultados estan dados en la misma unidad que se introduce.</p>
<table>
  <tr>
    <th>
      <p>
        <label>Radio de un Circulo</label>
        <input id="inputradio" type="number" placeholder="Radio" oninput="LengthConverter9(this.value)" onchange="LengthConverter9(this.value)">
      </p>
      <p>Area: <span id="outputArea"></span></p>

      <script>
        function LengthConverter9(valNum9) {
          document.getElementById("outputArea").innerHTML = (valNum9 * valNum9) * 3.14159265359;
        }
      </script>
    </th>
    <th>
      <p>
        <label>Lado de un Cuadrado</label>
        <input id="inputLado" type="number" placeholder="Largo" oninput="LengthConverter10(this.value)" onchange="LengthConverter10(this.value)">
      </p>
      <p>Area: <span id="outputArea1"></span></p>

      <script>
        function LengthConverter10(valNum10) {
          document.getElementById("outputArea1").innerHTML = (valNum10 * valNum10);
        }
      </script>

      <tr>
        <th>
          <p>
            <label>Base de un Triangulo Rectangulo</label>
            <input id="inputBase" type="number" placeholder="Ancho">
          </p>
          <p>
            <label>Altura de dicho Triangulo</label>
            <input id="inputAltura" type="number" placeholder="Alto" oninput="LengthConverter11(this.value)" onchange="LengthConverter11(this.value)">
          </p>
          <p>Area: <span id="outputArea4"></span></p>
          <script>
            function LengthConverter11(height) {
              var base = document.getElementById("inputBase").value.trim();
              console.log(base, height);
              height = height.trim();

              document.getElementById("outputArea4").innerHTML = (base * height) / 2;
            }
          </script>


        </th>
      </tr>
</table>

09-25 22:55