title: Calculate triangle area and circumference from user input sides
body: <p>I am trying to write a program that calculates the area and the circumference of a triangle from the user's input. (They're supposed to input the sides).</p>
  
  <p>This is all I have and for some reason (which I can't understand well enough to look up), it's not working. </p>
  
  <pre><code>&lt;html&gt;
       &lt;head&gt;
          &lt;title&gt;Triangle's Area &amp; Perimeter&lt;/title&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
          &lt;script type="text/javascript"&gt;
  
             function Triangle(side1,side2,side3){
  
                  this.side1 = side1;
                  this.side2 = side2;
                  this.side3 = side3; 
  
                  this.getArea = function(){
                       return s = (this.side1 + this.side2 + this.side3)/2;
                       area = squareRoot(s * (s-side1) * (s-side2) * (s-side3)); 
                  };
  
                  this.getPerimeter = function(){
                      return side1 + side2 + side3;
                  };
  
                  this.toString = function(){
                      return "The Triangle with sides = " + this.side1 + this.side2 + this.side3 + " has Area = " + this.getArea() + " and Perimeter = " + this.getPerimeter();
                  };
              }
  
              function calculate(){
  
                  var s = parseFloat(document.getElementById('side1','side2','side3').value);
  
  
                  if(isNaN(s)){
                      document.getElementById('data').innerHTML = "Please  enter numbers only";
                      return;
                  }
  
                  if(s&lt;=0){
                      document.getElementById('data').innerHTML = "Negative  numbers and Zero don't   make   sense";
                      return;
                  }
  
  
                  var myTriangle = new Triangle();
  
                  document.getElementById('data').innerHTML = myTriangle.toString();
  
              }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;h3&gt;Program Calculates Area and Perimeter of Triangles&lt;/h3&gt;
      &lt;p&gt;Enter the side1: &lt;input type="text" id="side1" value="" /&gt;
      &lt;p&gt;Enter the side2: &lt;input type="text" id="side2" value="" /&gt;
      &lt;p&gt;Enter the side3: &lt;input type="text" id="side3" value="" /&gt;
      &lt;input type="button"  value="Calculate"  onClick="calculate()" /&gt;&lt;/p&gt;
  
      &lt;p id="data"&gt;&lt;/p&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>